我想加入兩個數組,其中1個鍵應該加入它們。PHP合併數組並保留鍵
array:1 [
0 => array:2 [
"MONAT" => "AUG"
"MAIL_CNT" => "2"
]
1 => array:2 [
"MONAT" => "JUL"
"MAIL_CNT" => "1"
]
]
array:2 [
0 => array:2 [
"MONAT" => "AUG"
"ORDER_CNT" => "18"
]
1 => array:2 [
"MONAT" => "JUL"
"ORDER_CNT" => "1"
]
]
結果應該是這樣的
array:1 [
0 => array:2 [
"MONAT" => "AUG"
"MAIL_CNT" => "2"
"ORDER_CNT" => "18"
]
1 => array:2 [
"MONAT" => "JUL"
"MAIL_CNT" => "1"
"ORDER_CNT" => "1"
]
]
我無法弄清楚該怎麼做。
在此先感謝和問候!
可能重複的[PHP:合併兩個數組,同時保留鍵而不是重新索引?](https://stackoverflow.com/questions/3292044/php-merge-two-arrays-while-keeping-keys-instead-of -reindexing) – Difster
您的關鍵MONAT應該與兩者匹配嗎?該條件? – Alice