Gen. partnerAlgotech

PHP function array_search()

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

|
September 11, 2019

Availability in versions: PHP 4.0.5

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

Parameters

Parameter Data type Default value Note
$needle mixed not The searched value.
$haystack array not The array.
$strict bool null

Return values

mixed

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

If needle is found in haystack more than once, the first matching key is returned. To return the keys for all matching values, use array_keys with the optional search_value parameter instead.

Additional resources

Official array-search documentation

Loading comments...

Stay in the loop

Subscribe to our newsletter and get the latest cybersecurity news delivered straight to your inbox.

Your data is safe. You can unsubscribe from the newsletter at any time.