这是我的密码,
我的问题是,来自前一个的$company_id
是否等于来自前两个的$Company_id
,然后是echo company_name
。
$ids = array();
$x = array();
$a = array();
foreach($companieslist as $keys=>$company) {
$x[$company->company_id] = [
'id' => $company->company_id,
'name' => $company->company_name
];
}
$entry = $a[$id];
foreach($uploads as $keys=>$general){
$ids[] = $general->Contract_Id;
$c_id = $general->Company_id;
....
答案 0 :(得分:0)
仅仅从性能方面来说,您应该做的就是先将第二批的公司ID提取到数组中,就像这样
$companies = array();
foreach ( $uploads as $keys => $general ) {
array_push( $companies, $general->Company_id );
}
现在,在第一个foreach循环中,您只需检查该$ companies数组中是否存在公司ID,然后决定要做什么
foreach($companieslist as $keys=>$company){
if(in_array($company->company_id,$companies)){
echo "Found {$company->company_id}<br/>\n";
}
}