I have a list of arrays (for this example I use cell phones). I want to be able to search for multiple key / value pairs and return the index of the parent array.
For example, here is my array:
// $list_of_phones (array) Array ( [0] => Array ( [Manufacturer] => Apple [Model] => iPhone 3G 8GB [Carrier] => AT&T ) [1] => Array ( [Manufacturer] => Motorola [Model] => Droid X2 [Carrier] => Verizon ) )
I want to be able to do something like the following:
// This is not a real function, just used for example purposes $phone_id = multi_array_search( array('Manufacturer' => 'Motorola', 'Model' => 'Droid X2'), $list_of_phones ); // $phone_id should return '1', as this is the index of the result.
Any ideas or suggestions on how I can or should do this?
arrays php multidimensional-array
Wes foster
source share