php find a particular element in multidimensional array code example
Example: php search multidimensional array for multiple values
function multi_array_search($array, $search) {
$result = array();
foreach ($array as $key => $value){
foreach ($search as $k => $v){
if (!isset($value[$k]) || $value[$k] != $v){
continue 2;
}
}
$result[] = $key;
}
return $result;
}
print_r(multi_array_search($list_of_phones, array()));
print_r(multi_array_search($list_of_phones, array('Manufacturer' => 'Apple')));
print_r(multi_array_search($list_of_phones, array('Manufacturer' => 'Apple', 'Model' => 'iPhone 6')));