我希望所有数组都使用pubsite_id = 8,这是最佳方式。我可以使用foreach来做到这一点,但是当它变大时它似乎非常昂贵。
array(
array( "startdate" => "2014-02-01",
"enddate" => "2014-02-13",
"pubsite_id" => "1",
"dfp_order_id" => "116260016",
"amount" => "-5000.00000",
"amountperday" => -384.61538461538
),
array( "startdate" => "2014-02-01",
"enddate" => "2014-02-28",
"pubsite_id" => "8",
"dfp_order_id" => "116260016",
"amount" => "-700.00000",
"amountperday" => -25
),
...
)
答案 0 :(得分:1)
Per @ deceze的建议,array_filter
是一个很好的,干净的方式,并且会表现得很好:
$filtered_arr = array_filter( $arr, function( $item ) {
return $item["pubsite_id"] == "8";
} )
答案 1 :(得分:-1)
foreach($array as $value)
{
foreach($value as $key => $val)
{
if($val['pubsite_id'] == "8")
{
/*your stuff */
}
}
}