freezemage0 / array_find
Provides array_find function.
Installs: 838
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/freezemage0/array_find
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.