How to search through subarrays efficiently in PHP?
$arr = array($arr1,$arr2,..);
How to search through $arr
to fin开发者_Python百科d the one with key1 => 'something'
,key2 => 'something else'
You can iterate over a nested array with Iterators, e.g.
$iterator = new RecursiveIteratorIterator(
new RecursiveArrayIterator($nestedArray),
RecursiveIteratorIterator::SELF_FIRST);
foreach($iterator as $key => val) {
if($key === 'something') {
echo $val;
}
}
Alternatively, have a look at array_walk_recursive
精彩评论