freezemage0 / array_find
Provides array_find function.
1.0.1
2023-10-03 08:37 UTC
Requires
- php: >=7.4
Requires (Dev)
- phpunit/phpunit: ^10.3
README
It's baffling that PHP in [current year] does not have a built-in array_find
function, so here it is.
Usage
<?php use function Freezemage\ArrayUtils\find as array_find; $items = [1, 2, 3]; array_find($items, fn (int $item): bool => $item % 2 === 0); // prints 2
Also passes key associated with the value as a second parameter of a callback.