Laravel Collection - takeUntil

3 years 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",
     ],
   }
New course: Desktop apps with Electron