Answers for "laravel collection remove item"

PHP
1

laravel collection remove item

forget()
The forget method removes an item from the collection by its key:

$collection = collect(['name' => 'taylor', 'framework' => 'laravel']);

$collection->forget('name');

$collection->all();

// ['framework' => 'laravel']

Another example

$permissions->forget([2, 3, 4]);

Source 
https://laravel.com/docs/8.x/collections#method-forget
Posted by: Guest on May-19-2021

Code answers related to "laravel collection remove item"

Browse Popular Code Answers by Language