1function find_customer_mobile($customers, $mobile) {
2 foreach($customers as $index => $cust) {
3 if($cust['mobile'] == $mobile) return $index;
4 }
5 return FALSE;
6}
1 /**
2 * PHP Search an Array for multiple key / value pairs
3 */
4
5 function multi_array_search($array, $search) {
6 // Create the result array
7 $result = array();
8
9 // Iterate over each array element
10 foreach ($array as $key => $value){
11
12 // Iterate over each search condition
13 foreach ($search as $k => $v){
14
15 // If the array element does not meet the search condition then continue to the next element
16 if (!isset($value[$k]) || $value[$k] != $v){
17 continue 2;
18 }
19 }
20 // Add the array element's key to the result array
21 $result[] = $key;
22 }
23
24 // Return the result array
25 return $result;
26 }
27
28 // Output the result
29 print_r(multi_array_search($list_of_phones, array()));
30
31 // Array ( [0] => 0 [1] => 1 )
32
33 // Output the result
34 print_r(multi_array_search($list_of_phones, array('Manufacturer' => 'Apple')));
35
36 // Array ( [0] => 0 )
37
38 // Output the result
39 print_r(multi_array_search($list_of_phones, array('Manufacturer' => 'Apple', 'Model' => 'iPhone 6')));
40
41 // Array ( )
42