欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

合并二维数组的有关问题

程序员文章站 2022-06-11 13:52:45
...
合并二维数组的问题
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 (
'108-3752685-0517825' =>
array (
0 => '6300-00',
),
'107-5010391-7170621' =>
array (
0 => '0054-00',
),
'105-5621773-8281824' =>
array (
0 => '0049-00',
),
);
$b = array (
'2200320000123' =>
array (
0 => '0054-00',
),
'2200320123501' =>
array (
0 => '0049-00',
),
'220032012395200' =>
array (
0 => '0049-00',
),
);
$t = array_merge($a, $b);
print_r($t);
Array
(
[108-3752685-0517825] => Array
(
[0] => 6300-00
)

[107-5010391-7170621] => Array
(
[0] => 0054-00
)

[105-5621773-8281824] => Array
(
[0] => 0049-00
)

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

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

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

)

合并二维数组的有关问题

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频