陣列我有含有2個陣列數據。我想能夠將它們添加在一起,以便第二個數組中的信息連接到第一個數組中。目前我正在做的array_merge將第二個數組添加到第一個數組的末尾。合併與現有的陣列的PHP
陣列1
[1] => Array
(
[0] => 2017-07-13 00:00:00
[1] => Foo
[2] => Bar
[3] => 16.11
[4] => 80.56
[5] => 96.67
)
[2] => Array
(
[0] => 2017-07-13 00:00:00
[1] => Foo
[2] => Bar
[3] => 1.23
[4] => 50.69
[5] => 14.24
)
陣列2
[1] => Array
(
[0] => TIME
[1] => Lorem
[2] => Ipsum
)
[2] => Array
(
[0] => TIME
[1] => Some
[2] => Text
)
如何可以合併兩個陣列,以便輸出變成如下面?
陣列3
[1] => Array
(
[0] => 2017-07-13 00:00:00
[1] => Foo
[2] => Bar
[3] => 16.11
[4] => 80.56
[5] => 96.67
[6] => TIME
[7] => Lorem
[8] => Ipsum
)
[2] => Array
(
[0] => 2017-07-13 00:00:00
[1] => Foo
[2] => Bar
[3] => 1.23
[4] => 50.69
[5] => 14.24
[6] => TIME
[7] => Some
[8] => Text
)
什麼正在發生
[1] => Array
(
[0] => 2017-07-14 00:00:00
[1] => Foo
[2] => Bar
[3] => 16.11
[4] => 80.56
[5] => 96.67
)
[2] => Array
(
[0] => 2017-07-14 00:00:00
[1] => Foo
[2] => Bar
[3] => 1.23
[4] => 50.69
[5] => 14.24
)
[3] => Array
(
[0] => TIME
[1] => Lorem
[2] => Ipsum
)
[4] => Array
(
[0] => TIME
[1] => Some
[2] => Text
)
我試圖array_merge($array1 , $array2);
但其將所述第二數組的第一個的端部。
任何想法?
每個陣列中有2個陣列,因此與對口,而不是主陣列合併的每個那些陣列。 – WheatBeak
你試過['array_merge_recursive()'](http://php.net/manual/en/function.array-merge-recursive.php)嗎? – axiac