想知道是否可以做任何改进来加速这个数组?
测试数组行数为 40,000 条记录。
循环完成需要很长时间。
样本值:
$test[] = array(
'products_id' => $data['products_id'],
'products_extra_fields_id' => $data['products_extra_fields_id'],
'products_extra_fields_name' => $data['products_extra_fields_name'],
'products_extra_fields_value' => $data['products_extra_fields_value']
);
foreach productid
{
$colname="column name";
//this inside for loop making thing very slow
foreach ($test as $key1 => $row1)
{
$w= $row1['products_id'];
$x= $row1['products_extra_fields_id'];
$y= $row1['products_extra_fields_name'];
$z= $row1['products_extra_fields_value'];
if( ($w==$products_id) && ($y== $colname) )
{
$wantedvalue=$z;
break;
}
}
}