目前,我有2個多維數組,我正在尋找將它們組合成一個巨型數組,其中數組1中的值名稱與數組2中的值名稱匹配。 數組的外觀作爲跟隨...PHP - 基於值的合併2多維數組
Array1
(
[0] => Array
(
[id] => 1
[name] => test1
[desc] => test_desc
[quantity] => 3
)
[1] => Array
(
[id] => 2
[name] => test2
[desc] => test_desc
[quantity] => 33
)
)
Array2
(
[0] => Array
(
[holder] => 'John'
[name] => test1
[desc] => test_desc
[location] => ATL
)
[1] => Array
(
[holder] => 'Jackie'
[name] => test3
[desc] => test_desc
[location] => SF
)
)
我正在尋找合併其中陣列1的「名稱」列數組2相匹配的陣列以及在陣列的1 & 2相結合的列到最後一個數組。這看起來像...
FinalArray
(
[0] => Array
(
[id] => 1
[holder] => 'John'
[name] => test1
[desc] => test_desc
[location] => ATL
[quantity] => 3
)
[1] => Array
(
[holder] => 'Jackie'
[name] => test3
[desc] => test_desc
[location] => SF
)
[2] => Array
(
[id] => 2
[name] => test2
[desc] => test_desc
[quantity] => 33
)
)
凡「測試1」融合了跨2個陣列的不同列到裏面的「FinalArray」一個新的數組。我試着用array_merge和array_merge_recursive來研究一些想法,但我不完全確定我是否會朝着正確的方向前進。提前致謝。
讓我們瞭解您到目前爲止 – RiggsFolly