php multidimensional array search by value

Solutions on MaxInterview for php multidimensional array search by value by the best coders in the world

showing results for - "php multidimensional array search by value"
Alan
06 Jan 2021
1$key = array_search('100', array_column($userdb, 'uid'));
2
Dean
31 Apr 2018
1function find_customer_mobile($customers, $mobile) {
2    foreach($customers as $index => $cust) {
3        if($cust['mobile'] == $mobile) return $index;
4    }
5    return FALSE;
6}
Hanna
20 Oct 2020
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
queries leading to this page
php array search multiple valuessearch in array multidimensional phpfind string in multidimensional array phpsearch array php 2 dimensionalhow to search 2 dimensional array in phpmultidimensional array find value in phpphp array search with multiple valuesphp multidimensional array search by valuephp search array key in multidimensional arrayphp search multiple values in arrayphp search array multidimensionalphp array multidimensional match valuephp in array multiple searchphp search and print value from array multidimensionalmultidimensional array search with multiple array column phpin array php multidimensional search product key return pricephp array multidimensional searchphp array search multidimensional arrayphp multi array search valuesearch value multidimensional array phpphp search in array multiple valuesarray search multidimensional phpphp search value in multidimensional arrayphp find pattern in 2 dimensional arrayphp array search multidimensional all keysarray search for two dimensional by column in phpphp search value in multidimensional associative arraysearch fromm multi dimensional array phparray search php multidimensional get arrayphp search value in 2d arrayphp array search value multidimensionalsearch a multidimensional array phpsearch string in multidimensional array phpfind array by value from a multidimensional array phpphp array return distinct multidimensional arrayphp search in multidimensional array by keyphp search key in multidimensional arrayphp search array in multidimensional arrayhow to search in multidimensional array phpsearch in multi array phpphp search multiple key values in arrayphp array search multidimensionalhow to use multiple array in array search in phpsearch item in 2darray phpphp find a particular element in multidimensional arrayfind element in multidimensional array phpsearch value in multidimensional array phparray search in multidimensional array phpfind a value in multidimensional array phpsearch php get multidimensional array keymulti array search phpstring search in multiple array phpphp multidimensional array search by keyphp multidimensional array searcharray search in php 2d arrayphp search in multidimensional associative arrayarray search multidimensional array phpfind multidimensional array phpfastest way to find an array in another multidimensional array phpmultidimensional array search in phparray one or multidimensional array to find out in phpmultidimensional array multiple search by value phpsearch in multidimensional array in phpfastest multidimensional array search in phpphp array search multidimensional by valuesearch name in array multidimensional phpmultidimensional array search with array columns phpmultidimensional array get value if match value phparray search multidimensional multiple array column phparray find with multiple conditions and multi multidimensional array phpphp array searach multi dimensional by valuemulti search php arraymatch multidimensional array in phpphp search 2 dimensional arrayphp search by key in multidimensional arrayphp search for sub array in multidimensional arraysearch 2 dimensional array phparray search multiple phpphp array search multidimensional by keyphp check all values of multidimensional array matchphp find in multidimensional array by valuemultiple dimensional array php search betweenmultidimensional array search by value phpphp multidimentional array search multiple valuesarray search function in php with multidimensionalsearch multidimensional array phpphp search multidimensional array for valuearray search in two dimensional array in phparray search in 2d array phpfind value in multidimensional array phpphp find in multidimentional arrayphp search multidimensional array for column valuephp multidimensional array find by valuephp find value in multidimensional arraysearch in array multidimensional php by vauephp search multidimensional array multiple valuesphp search multidimensional array for multiple key valuesphp array search multiple columnshow to search by key 3d 3evalue in a multidimensional array in phpphp find array value in multidimensionalsearch in multidimensional array to filter in phpphp array search in multidimensional arrayphp search nested multidimensional array by valuearray search in multidimensional phpphp find in array search multidimensionalmatch value through multidimesional array in phpphp search sub arrays by key multidimensional any levelsearch multidimensional array php by valuesearch and get value inside multidimentional array phparray search multidimensional php key and value php array search value multidimensional return recordarray search multiple value array multidimensional phpphp search multidimensional arrayphp search array multiple valuessearch column any multidimensional array in phpphp search multidimensional array by keyfind in multidimensional array phpreturn an array from multidimensional php matching a valuearray search multidimensional phparray search in php and return multiplesearch in array php 2 dimensionalphp find the array that has a value in multidimensionalsearch multidimensional array for value phpsearch multi dimensional array phpphp search multidimensional array for multiple valuesphp library array search multidimensionalmultidimention array search phpphp search string in multidimensional arrayphp array search multidimensionalarray search php multidimensionalmultidimensional array search by value in phparray search php multidimensional likesearch in every array php multi array searchphp search in multidimensional arraysearch in array multidimensional php by valuefind a value in a multidimensional array phpmultidimensional array search phpsearch multiple values in multidimensional array phparray search in multidimensional array phpmatch value in multidimensional array phpsearch array multidimensional phpsearch in multidimensional array phpget search value in multidimensional array phpphp multi array searchcount 2 dimensional array search phpphp search key value in multidimensional arraysearch array multiple values phpphp search value multidimensional arrayarray search key of value php on multidimensionalphp search in array multidimensionalphp multidimensional array search by value