reduce() 对集合中的元素累计操作
$collection = collect([1,2,3,4]);
return $collection->reduce(function($carry, $item){
return $carry += $item;
}, 0); // 10
$collection = collect([1,2,3,4]);
return $collection->reduce(function($carry, $item){
return $carry += $item;
}, 0); // 10
本文标题:laravel集合函数-reduce()
本文链接:https://www.haomeiwen.com/subject/jyygchtx.html
网友评论