-4
我有兩個關聯數組,我想根據數組的索引/鍵合併,我不希望它覆蓋索引中的任何數組值。基於索引合併2個數組而不覆蓋php
Array 1:
Array
(
[66529] => Array
(
[Download] => ON
)
[66587] => Array
(
[Download] => ON
)
)
Array 2:
Array
(
[66587] => Array
(
[PPT] => ON
)
[66529] => Array
(
[PPT] => OFF
)
)
合併完畢數組應該是:
Array
(
[66529] => Array
(
[Download] => ON
[PPT] => OFF
)
[66587] => Array
(
[Download] => ON
[PPT] => ON
)
)
我知道這可以通過循環來完成,但是我正在尋找內置PHP函數來做到這一點。
http://php.net/manual/en/function.array-merge-recursive.php#example-5522 –
[this]的可能重複(http://stackoverflow.com/questions/12051782/php- array-merge-recursive-preserving-numeric-keys) – DevDonkey
你不能在php數組中有重複的鍵,或者簡單地說:除非你改變鍵,它總是會被覆蓋。 – Peter