array_search
Searches an array for a specific value and returns the corresponding key if found, or false if not found.
Parameters
main.php
Return Values
int|string|false
Returns the key for needle if found, false otherwise
On success:The key (index) of the first matching value found in the array
On failure:false if the searched value is not found in the array
Notes
- Returns the key of the first matching value, not the value itself
- Use strict comparison (=== false) to distinguish between key 0 and false
- If multiple matches exist, only the first key is returned
- Set strict parameter to true for type-safe comparisons
Changelog
- 4.2.0: Function was introduced
- 5.3.0: strict parameter behavior improved