📜  从集合中删除项目 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:39.191000             🧑  作者: Mango

代码示例1
$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';
});