← All built-ins / array_search()

array_search()

array_search(...$args): mixed

Parameters

NameTypeDescription
$needlemixedvalue to find
$haystackarrayarray to search

Return value

The key of the first match, or false when not found.

Example

echo array_search(20, [10, 20, 30]);
1

See also

in_array()array_flip()array_key_exists()