count(filter(fn)($src)) in one step.
Creates a Closure that counts how many elements of an array or iterable pass the predicate.
/**
* @param callable(mixed):bool $function
* @return Closure(iterable<int|string, mixed>):int
*/
Arrays\filterCount(callable $function): ClosureWhen Arrays\filterCount() is called, it returns the following Closure which can be used like a regular function.
/**
* @param iterable<int|string, mixed> $source
* @return int
*/
$function (iterable $source): intThis can be used to create a simple closure which can be used as a regular function.
$evenCount = Arrays\filterCount(fn($v) => $v % 2 === 0);
echo $evenCount([1, 2, 3, 4, 5, 6]); // 3This can be called inline using currying.
echo Arrays\filterCount('is_string')([1, 'a', 2, 'b', null]); // 2