Home > PHP > Function > Arrays > array_search()

array_search()

array_search - Searches the array for a given value and returns the corresponding key if successful

Syntax

mixed array_search (mixed $needle, array $haystack, bool $strict)

Arguments

  • needle - The searched value. Note: If needle is a string, the comparison is done in a case-sensitive manner.
  • haystack - The array.
  • strict - If the third parameter strict is set to TRUE then the array_search() function will search for identicalelements in the haystack. This means it will also check the typesof the needle in the haystack, and objects must be the same instance.

Description

Searches haystack for needle.

Version

PHP 4.0.5, 5

Return value

Returns the key for needle if it is found in the array, FALSE otherwise.