Laravel - Collections - Method Skipwhile
The skipWhile
method skips over items from the collection while the given callback returns true
and then returns the remaining items in the collection as a new collection:
$collection = collect([1, 2, 3, 4]);
$subset = $collection->skipWhile(function ($item) {
return $item <= 3;
});
$subset->all();
// [4]
If the callback never returnstrue
, theskipWhile
method will return an empty collection.