Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

remove item from collection

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

// The forget method removes an item from the collection by its key:
$collection->forget('name');
// The pull method removes and returns an item from the collection by its key:
$collection->pull('name');
// The reject method filters the collection using the given closure.
// The closure should return true if the item should be removed from the resulting collection:
$filtered = $collection->reject(function ($value) {
    return $value == 'taylor';
});
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #remove #item #collection
ADD COMMENT
Topic
Name
8+8 =