我是 Laravel 的新手。我想要把两个多维数组合并成一个数组。我尝试使用 array_merge
函数,但它没有生效。我想要合并数组[0]位置的值和数组[1]位置的值。
这是我的当前数组:
Array
(
[0] => Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => stdClass Object
(
[product_id] => 2
[sale_datetime] => 2018-10-15 16:33:59
[name] => Tea
[totalqty] => 3
)
[1] => stdClass Object
(
[product_id] => 2
[sale_datetime] => 2018-10-16 10:44:14
[name] => Tea
[totalqty] => 5
)
)
)
[1] => Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => stdClass Object
(
[product_id] => 3
[sale_datetime] => 2018-11-15 18:04:36
[name] => Coffee
[totalqty] => 20
)
)
)
)
我想要创建一个像下面这样的数组:
Array
(
[0] => Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => stdClass Object
(
[product_id] => 2
[sale_datetime] => 2018-10-15 16:33:59
[name] => Tea
[totalqty] => 3
)
[1] => stdClass Object
(
[product_id] => 2
[sale_datetime] => 2018-10-16 10:44:14
[name] => Tea
[totalqty] => 5
)
[2] => stdClass Object
(
[product_id] => 3
[sale_datetime] => 2018-11-15 18:04:36
[name] => Coffee
[totalqty] => 20
)
)
)
)
$Details
数组好吗? - Oleg Nurutdinov