tags:

views:

136

answers:

3
$arr = array($arr1,$arr2,..);

How to search through $arr to find the one with key1 => 'something',key2 => 'something else'

A: 

Try exporting in a string, and doing a search on it

$string = var_export($ar, true);
Pentium10
This kind of code belongs on The Daily WTF.
Will Vousden
thinking today is (W)ednesday, so I should post on (T)hursday and (F)riday too? :)
Pentium10
A: 

I guess there are no memory-efficient way here. You will have to loop through each sub-array to find your content. do let know if you find some better solution.

--Pinaki

pinaki
This is not a forum. Please direct questions to answers via the *add comment* function below the question.
Gordon
Point taken....
pinaki
+2  A: 

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

Gordon