問(wèn)題描述
我需要將 2 個(gè)多維數(shù)組合并在一起以創(chuàng)建一個(gè)新數(shù)組.
這 2 個(gè)數(shù)組是從 $_POST
和 $_FILES
創(chuàng)建的,我需要它們相互關(guān)聯(lián).
I need to merge 2 multidimensional arrays together to create a new array.
The 2 arrays are created from $_POST
and $_FILES
and I need them to be associated with each other.
數(shù)組#1
數(shù)組#2
新數(shù)組
我正在使用的當(dāng)前代碼有效,但僅適用于數(shù)組中的最后一項(xiàng).
我假設(shè)通過(guò)循環(huán) array_merge
函數(shù),它會(huì)在每個(gè)循環(huán)中擦除我的新數(shù)組.
The current code i'm using works, but only for the last item in the array.
I'm presuming by looping the array_merge
function it wipes my new array every loop.
我該如何糾正?
推薦答案
[] 會(huì)將它附加到數(shù)組中而不是覆蓋.
the [] will append it to the array instead of overwriting.
這篇關(guān)于PHP:合并 2 個(gè)多維數(shù)組的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!