开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜