Laravel Collection - takeUntil

1 month ago

kenmush

This collection method allows you to take items from your collection upto the specified key

Code

$countries = collect(['Kenya', 'Uganda', 'Tanzania', 'Ethiopia', 'Rwanda']);

$countries->takeUntil('Ethiopia');

Output

=> Illuminate\Support\Collection {#1902
     all: [
       "Kenya",
       "Uganda",
       "Tanzania",
     ],
   }
HELO: Local email testing for your desktop!