阅读(2893) (9)

Laravel 8 collapse() {#collection-method}

2021-07-01 14:27:48 更新

collapse 方法把一个多数组集合平铺为单个扁平的集合:

$collection = collect([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);

$collapsed = $collection->collapse();

$collapsed->all();

// [1, 2, 3, 4, 5, 6, 7, 8, 9]