filter()
The filter() method creates a new array with all elements that pass the function.
<?php use kim\present\utils\arrays\ArrayUtils;
$arrayUtils = ArrayUtils::from(range(1, 10));
//Filtering values between 3 and 6
$arrayUtils->filter(function($num){ return $num < 3 || $num > 6; });
// expected output: [1, 2, 7, 8, 9, 10]Syntax
$arrayUtils->filter(callable $callback) : ArrayUtils;Parameter
Return value
Prefixing
References
Last updated