Home > Backend Development > PHP Tutorial > 合并二维数组的问题

合并二维数组的问题

WBOY
Release: 2016-06-23 13:38:14
Original
1007 people have browsed it

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);
Copy after login
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        ))
Copy after login

$new_order_list=GetSaleOrder('new',1);$re_order_list=GetSaleOrder('re',1);$order_list=array_merge( $new_order_list, $re_order_list );print_r($new_order_list);print_r($re_order_list);print_r($order_list);
Copy after login


Array ( [250-5564686-0137465] => Array ( [0] => 6677-00 ) [250-1149332-5735041] => Array ( [0] => 6650-01 ) [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 ( [250-5564686-0137465] => Array ( [0] => 6677-00 ) [250-1149332-5735041] => Array ( [0] => 6650-01 ) [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 ) ) 
Copy after login

但我的结果就是不对,也不知道哪里错了

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template