Home  >  Article  >  Backend Development  >  合并二维数组的有关问题

合并二维数组的有关问题

WBOY
WBOYOriginal
2016-06-13 12:16:42810browse

合并二维数组的问题
Array ( [108-3752685-0517825] => Array ( [0] => 6300-00 ) [107-5010391-7170621] => Array ( [0] => 0054-00 ) [105-5621773-8281824] => Array ( [0] => 0049-00 ) )

Array ( [2200320000123] => Array ( [0] => 0054-00 ) [2200320123501] => Array ( [0] => 0049-00 ) [220032012395200] => Array ( [0] => 0049-00 ) )

Array ( [108-3752685-0517825] => Array ( [0] => 6300-00 ) [107-5010391-7170621] => Array ( [0] => 0054-00 ) [105-5621773-8281824] => Array ( [0] => 0049-00 ) [0] => Array ( [0] => 0054-00 ) [1] => Array ( [0] => 0049-00 ) [2] => Array ( [0] => 0049-00 ) )

用array_merge合并后,第二个数组的键名没有了,是我用法不对??
------解决思路----------------------
不是这样的吗?

$a = array (<br />  '108-3752685-0517825' => <br />  array (<br />    0 => '6300-00',<br />  ),<br />  '107-5010391-7170621' => <br />  array (<br />    0 => '0054-00',<br />  ),<br />  '105-5621773-8281824' => <br />  array (<br />    0 => '0049-00',<br />  ),<br />);<br />$b = array (<br />  '2200320000123' => <br />  array (<br />    0 => '0054-00',<br />  ),<br />  '2200320123501' => <br />  array (<br />    0 => '0049-00',<br />  ),<br />  '220032012395200' => <br />  array (<br />    0 => '0049-00',<br />  ),<br />);<br />$t = array_merge($a, $b);<br />print_r($t);
Array<br />(<br />    [108-3752685-0517825] => Array<br />        (<br />            [0] => 6300-00<br />        )<br /><br />    [107-5010391-7170621] => Array<br />        (<br />            [0] => 0054-00<br />        )<br /><br />    [105-5621773-8281824] => Array<br />        (<br />            [0] => 0049-00<br />        )<br /><br />    [2200320000123] => Array<br />        (<br />            [0] => 0054-00<br />        )<br /><br />    [2200320123501] => Array<br />        (<br />            [0] => 0049-00<br />        )<br /><br />    [220032012395200] => Array<br />        (<br />            [0] => 0049-00<br />        )<br /><br />)<br /><br />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn