0
我已經看過這個網站,並找到了一些合併數組的示例,但說實話,我不確定哪一個適合我。我怎樣才能將兩個數組合併爲一個
我很難嘗試合併這些數組。我試過array_combine和array_merge,但我沒有任何運氣。
我所需要的是一個單一的陣列,這樣的輸出:
Array
(
[0] => Array
(
[UnitNo] => 91
[Name] => Receiving
[ActivityNo] =>
[Active] => 2
[CallNo] =>
[CallStatusNo] =>
[Assigned] =>
[UnitId] => 2
)
[1] => Array
(
[UnitNo] => 83
[Name] => Shipping
[ActivityNo] =>
[Active] =>
[CallNo] =>
[CallStatusNo] =>
[Assigned] =>
[UnitId] => 1
)
)
這些是兩個陣列,我需要基於所述UnitId
應該形成像上面的一個完整的陣列合併到一起。我只是不知道該怎麼做。如果有人能指導我,我會很感激。
// Array #1
Array
(
[0] => Array
(
[UnitId] => 2
[UnitNo] => 91
[Name] => Receiving
[Active] => 4
)
[1] => Array
(
[UnitId] => 1
[UnitNo] => 83
[Name] => Shipping
[Active] => 4
)
)
// Array #2
Array
(
[0] => Array
(
[UnitId] => 2
[ActivityNo] => 1
[CallNo] => 1
[CallStatusNo] => 1
[Assigned] => 1
)
[1] => Array
(
[UnitId] => 1
[ActivityNo] => 11
[CallNo] => 2
[CallStatusNo] => 1
[Assigned] => 1
)
)
你應該看看文檔:http://php.net/manual/en/function.array-merge.php – Lefsler
@demonofnight,謝謝。如果array_merge會爲我工作,那麼我會更多地研究這個函數。我只是想確定它會做我所需要的。謝謝! – NaN