我有一個像下面的多數組,如果一個鍵(其他人)是一個數組需要合併。我嘗試使用array_merge(call_user_func_array('array_merge',$ myArr))並且它沒有按預期工作。php合併到相同的數組,如果鍵是數組
Array
(
[12] => Australia
[36] => Canada
[82] => Germany
[97] => Hong Kong
[100] => India
[154] => New Zealand
[190] => Singapore
[222] => United Arab Emirates
[223] => United Kingdom
[224] => United States of America
[Others] => Array
(
[1] => Afghanistan
[3] => Algeria
[4] => Andorra
[6] => Anguilla
)
)
我該如何轉換爲像下面一樣丟失密鑰。
Array
(
[12] => Australia
[36] => Canada
[82] => Germany
[97] => Hong Kong
[100] => India
[154] => New Zealand
[190] => Singapore
[222] => United Arab Emirates
[223] => United Kingdom
[224] => United States of America
[1] => Afghanistan
[3] => Algeria
[4] => Andorra
[6] => Anguilla
)
更新 我能做到這樣,但我不知道這是做它的方式。
$temp = $myArr['others'];
unset($myArr['others']);
array_replace($myArr , $temp);
向我們展示你的最好的嘗試,讓我們看到正是你失敗了。 – zerkms 2015-03-03 06:26:27
它總是被稱爲「其他」嗎?還是可以有其他內部數組? – 2015-03-03 06:47:16
是的,它始終是相同的數組。 – 2015-03-03 06:48:08