'eight' => 8,
]);
$diff->all(); // ['one' => 10, 'three' => 30, 'five' => 50]
#12.each方法
#迭代集合中的内容并将其传递到回调函数中...collection->except(['price', 'discount']);
$filtered->all(); // ['product_id' => 1]
#15.filter方法,使用给定的回调函数过滤集合的内容...collection->filter(function ($value, $key) {
return $value > 2;
});
$filtered->all(); // [3, 4]
#如果没有提供回调函数...#52.reject方法,使用指定的回调过滤集合。如果回调返回 true ,就会把对应的项目从集合中移除。...' => 200]);
$collection->toJson(); // '{"name":"Desk", "price":200}'
#69.transform方法,迭代集合并对集合内的每个项目调用给定的回调