我有2個數組。我想合併它們。數組與多維數組合並
陣列1:
Array
(
[100] =>
[50] =>
[CREDIT] => 14.31
[CHEQUE] =>
)
陣列2:
Array
(
[0] => Array
(
[id] => 501
)
[1] => Array
(
[id] => 502
)
[2] => Array
(
[id] => 503
)
我與$array1+$array2
合併後,他們得到這個結果:
Array
(
[100] =>
[50] =>
[CREDIT] => 14.31
[CHEQUE] =>
[0] => Array
(
[id] => 501
)
)
而且我EXPE結果是:
Array
(
[100] =>
[50] =>
[CREDIT] => 14.31
[CHEQUE] =>
[0] => Array
(
[0] => Array
(
[id] => 501
)
[1] => Array
(
[id] => 502
)
[2] => Array
(
[id] => 503
)
)
)
可能是什麼原因?謝謝。
你嘗試過'array_merge($ array1,$ array2)'嗎? – Mir 2014-09-26 16:50:07
我的數組中有數字'KEYS'。我無法使用該功能。 – 2014-09-26 16:50:36
'$ array1 [0] = $ array2'如何? – Sadiq 2014-09-26 16:59:46