Iterates over each value in the collection passing them to the callback function. If the callback function returns true,
the current value from collection is returned into the result collection. Keys are preserved. You can use the key to filter.
- fn
- Filter to apply to every item in the collection.
- coll
- Collection of values to be filtered.
Filter numbers biggers than 10:
<?php
use function Lambdish\Phunctional\filter;
return filter(
static function ($number) {
return $number > 10;
},
[1, 20, 3, 40, 5]
);
// => [20, 40]