You want array_keys with the search value

array_keys($list[0], "2009-09-09");

which will return an array of the keys with the specified value, in your case [0, 2]. If you want to find the duplicates as well, you can first make a pass with array_unique, then iterate over that array using array_keys on the original; anything which returns an array of length > 1 is a duplicate, and the result is the keys in which the duplicates are stored. Something like...

$uniqueKeys = array_unique($list[0])

foreach ($uniqueKeys as $uniqueKey)
{
  $v = array_keys($list[0], $uniqueKey);

  if (count($v) > 1)
  {
    foreach (key)
    {
      // Work with $list[0][$key]
    }

  }
}
Answer from Adam Wright on Stack Overflow
🌐
PHP
php.net › manual › en › function.array-search.php
PHP: array_search - Manual
If the third parameter strict is set to true then the array_search() function will search for identical elements in the haystack. This means it will also perform a strict type comparison of the needle in the haystack, and objects must be the ...
🌐
W3Schools
w3schools.com › php › func_array_search.asp
PHP array_search() Function
AJAX Intro AJAX PHP AJAX Database AJAX XML AJAX Live Search AJAX Poll · PHP Examples PHP Compiler PHP Quiz PHP Exercises PHP Server PHP Syllabus PHP Study Plan PHP Certificate ... array() array_change_key_case() array_chunk() array_column() array_combine() array_count_values() array_diff() array_diff_assoc() array_diff_key() array_diff_uassoc() array_diff_ukey() array_fill() array_fill_keys() array_filter() array_flip() array_intersect() array_intersect_assoc() array_intersect_key() array_intersect_uassoc() array_intersect_ukey() array_key_exists() array_keys() array_map() array_merge() array
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-search-by-multiple-key-value-in-php-array
How to search by multiple key => value in PHP array ? - GeeksforGeeks
July 15, 2024 - To search for elements in a PHP array based on multiple key-value pairs without using foreach, utilize array_filter() with a callback that checks matches using array_intersect_assoc().
🌐
Medium
medium.com › @rodgersj097 › how-to-search-a-multi-dimensional-array-in-php-with-internal-functions-2d08a5eb4363
How to search a multi-dimensional array in PHP with internal functions. | by Jacob Rodgers | Medium
October 1, 2020 - To solve this in the past I would have written a function like so · function arraySearch($foo, $2dArray){ foreach($array as $key => $val){ if($val['model']=== $foo){ return $val; } } return null; }
🌐
GeeksforGeeks
geeksforgeeks.org › php › php-multidimensional-array-search-by-value
PHP multidimensional array search by value - GeeksforGeeks
July 11, 2025 - This function only returns the key index instead of a search path. The array_column() function returns the values from a single column in the input array. Example: ... <?php // PHP program to carry out multidimensional array search // Multidimensional array $gfg_array = array( array( 'score' => '100', 'name' => 'Sam', 'subject' => 'Data Structures' ), array( 'score' => '50', 'name' => 'Tanya', 'subject' => 'Advanced Algorithms' ), array( 'score' => '75', 'name' => 'Jack', 'subject' => 'Distributed Computing' ) ); $id = array_search('50', array_column($gfg_array, 'score')); echo $id; ?>
🌐
Clue Mediator
cluemediator.com › multidimensional-array-search-by-value-in-php
Multidimensional array search by value in PHP - Clue Mediator
array_search($value['id'], array_column($employeesData, 'emp_id')); Let’s use the following code to get the output. <!--?php foreach($employees as $key =--> $value){ $index = array_search($value['id'], array_column($employeesData, 'emp_id')); $email = ($index!== false) ?
🌐
Uptimia
uptimia.com › home › questions › how to search a php multidimensional array by value?
How To Search A PHP Multidimensional Array By Value?
November 5, 2024 - Two useful functions are array_column() and array_search(). array_column() takes a column from a multidimensional array. It needs three inputs: the array, the column key to extract, and an optional index key.
Find elsewhere
🌐
3D Bay
clouddevs.com › home › php guides › working with php’s array_search() function: a practical guide
Working with PHP's array_search() Function: A Practical Guide
December 11, 2023 - One important consideration is that array_search() returns false both when a value is not found and when the value is found at key 0. This can lead to unexpected results, especially in indexed arrays. To avoid this, you should use the !== operator to check for both value and type. ... php $colors = ['red', 'green', 'blue']; $position = array_search('red', $colors); if ($position !== false) { echo 'The key of "red" is ' .
Top answer
1 of 6
256

Intersect the targets with the haystack and make sure the intersection count is equal to the target's count:

Copy$haystack = array(...);

$target = array('foo', 'bar');

if(count(array_intersect($haystack, $target)) == count($target)){
    // all of $target is in $haystack
}

Note that you only need to verify the size of the resulting intersection is the same size as the array of target values to say that $haystack is a superset of $target.

To verify that at least one value in $target is also in $haystack, you can do this check:

Copy if(count(array_intersect($haystack, $target)) > 0){
     // at least one of $target is in $haystack
 }
2 of 6
246

Searching the array for multiple values corresponds to the set operations (set difference and intersection), as you will see below.

I also provide usage examples that clearly demonstrate both options.

ALL needles exist

Copyfunction in_array_all(array $needles, array $haystack): bool {
    return array_diff($needles, $haystack) === [];
}

$animals = ["bear", "tiger", "zebra"];
in_array_all(["bear", "zebra"], $animals); // true, both are animals
in_array_all(["bear", "toaster"], $animals); // false, toaster is not an animal

ANY of the needles exist

Copyfunction in_array_any(array $needles, array $haystack): bool {
    return array_intersect($needles, $haystack) !== [];
}

$animals = ["bear", "tiger", "zebra"];
in_array_any(["toaster", "tiger"], $animals); // true, tiger is an amimal
in_array_any(["toaster", "brush"], $animals); // false, no animals here

Important consideration

If the set of needles you are searching for is small and known upfront, your code might be clearer if you just use the logical chaining of in_array calls, for example:

Copy$animals = getAllAnimals();
$all = in_array("tiger", $animals) && in_array("toaster", $animals) && ...
$any = in_array("bear", $animals) || in_array("zebra", $animals) || ...
Top answer
1 of 7
27

Perhaps this will be useful:

  /**
   * Multi-array search
   *
   * @param array $array
   * @param array $search
   * @return array
   */
  function multi_array_search($array, $search)
  {

    // Create the result array
    $result = array();

    // Iterate over each array element
    foreach ($array as $key => $value)
    {

      // Iterate over each search condition
      foreach ($search as $k => $v)
      {

        // If the array element does not meet the search condition then continue to the next element
        if (!isset($value[$k]) || $value[$k] != $v)
        {
          continue 2;
        }

      }

      // Add the array element's key to the result array
      $result[] = $key;

    }

    // Return the result array
    return $result;

  }

  // Output the result
  print_r(multi_array_search($list_of_phones, array()));

  // Array ( [0] => 0 [1] => 1 )

  // Output the result
  print_r(multi_array_search($list_of_phones, array('Manufacturer' => 'Apple')));

  // Array ( [0] => 0 )

  // Output the result
  print_r(multi_array_search($list_of_phones, array('Manufacturer' => 'Apple', 'Model' => 'iPhone 6')));

  // Array ( )

As the output shows, this function will return an array of all keys with elements which meet all the search criteria.

2 of 7
6

I ended up doing the following. It's not pretty, but works very well. For anyone reading, feel free to update with a DRYer answer:

// Variables for this example
$carrier = 'Verizon';
$model = 'Droid X2';
$manufacturer = 'Motorola';

// The foreach loop goes through each key/value of $list_of_phones and checks
// if the given value is found in that particular array. If it is, it then checks
// a second parameter (model), and so on.
foreach ($list_of_phones as $key => $object)
{
    if ( array_search($carrier, $object) )
    {
        if ( array_search($model, $object) )
        {
            if ( array_search($manufacturer, $object) )
            {
                // Return the phone from the $list_of_phones array
                $phone = $list_of_phones[$key];
            }
        }
    }
}

Works like a charm.

🌐
Talkerscode
talkerscode.com › howto › php-search-multidimensional-array-for-multiple-values.php
PHP Search Multidimensional Array For Multiple Values
In this tutorial we will show you ... here we passing our associative array to the foreach() loop there we using another foreach loop for passing specified key, value pairs to find then we checking key values with array values ...
🌐
Nabilhassen
nabilhassen.com › php-search-multidimensional-array
Searching in a multidimensional array in PHP
October 15, 2025 - When you need to search by multiple criteria or across multiple levels, a simple loop gives full control. ... This approach is most flexible, you can add complex conditions, nested checks, or partial matches. It’s also easier to debug. array_filter() returns all elements for which the callback returns true. Keys are preserved; use array_values() to reindex if you want a zero-based result array.
🌐
In The Digital
inthedigital.co.uk › use-phps-in_array-to-compare-a-variable-to-multiple-values
Use PHP's in_array() to compare a variable to multiple values | In The Digital
August 28, 2020 - if (in_array($test_variable, ['value1', 'value2', 'value3', 'value4']) { // do something if $test_variable is equal to one of the strings in the array }