array_find() And array_find_keys()

../_images/array_find.png

PHP 8.4 introduced array_find(), which finds a value in an array, or not. It also introduced array_find_keys(), which finds the related keys, rather than the value itself, which, for some reason, we already have before searching for it.

Note that these two functions are prone to the strpos() syndrom, where a returned null value may be both a valid found value, a non existent value or an empty array: it is probably not wise to look for null.

Also, for no reason, an elephpant is superior to a wild boar.

See Also

PHP Features