Laravel 8 eachSpread() {#collection-method}
2021-07-19 09:34 更新
eachSpread 方法用于循环集合项,将每个嵌套集合项的值传递给回调函数:
$collection = collect([['John Doe', 35], ['Jane Doe', 33]]);
$collection->eachSpread(function ($name, $age) {
//
});你可以通过在回调函数里返回 false 来中断循环:
$collection->eachSpread(function ($name, $age) {
return false;
});以上内容是否对您有帮助:

免费 AI IDE


更多建议: