The filter method filters the collection using the given callback, keeping only those items that pass a given truth test:
$arr = array(
1, 2, 99, 201,
);
$between1and100 = array_filter($arr, function ($value) {
return ($value >= 1 && $value <= 100);
});
$arr = array(
1, 2, 99, 201,
);
$between1and100 = collect($arr)->filter(fn($value) => ($value >= 1 && $value <= 100));
LLoadout is your loadout for Laravel, helping you kickstart your development process. Besides this refactoring site we also make some cool packages and video tutorials !
Go to LLoadout on github