PHP array_search() function is used to search the array for a given value and returns the first corresponding key if successful. PHP array_search() function is PHP built-in function.
Syntax :
array_search(mixed $search , array $array, bool $strict = false);
Parameter,
$search : Required. It is searched value. If searched value is a string, the comparison is done in a case-sensitive manner.
$array : Required. It is input array.
$strict: Optional. Default value is false. If It is TRUE, checks identical type of the value.
Return : It returns the key for searched value if it is found in the array otherwise it returns false. If there are more than one matches, the first matched key will be returned.
Let's see below example to understand php array_search() Function in details.
Comments