参照数组合并-php 二维数组合并 以一个数组为参照,比它多的项删除,比它少的项增加,相同的增加
程序员文章站
2024-04-04 10:55:17
...
参照数组合并php数组合并
$a = array('01' => array('count'=>1, 'amount'=>100,'cesgu'=>33),
'02' => array('count'=>2, 'amount'=>200),
'03' => array('count'=>3, 'amount'=>250) );
$b = array('01' => array('count'=>4, 'amount'=>300),
'02' => array('count'=> 5, 'amount'=>400));
以$a 为参照
输出Array ( [01] => Array ( [count] => 5 [amount] => 400 [cesgu] => 33 ) [02] => Array ( [count] => 7 [amount] => 600 )
[03] => Array ( [count] => 3 [amount] => 250 ) )
如果以$b为参照的话
输出Array ( [01] => Array ( [count] => 5 [amount] => 400 [cesgu] => 33 ) [02] => Array ( [count] => 7 [amount] => 600 )
请教下大家,
上一篇: Linux笔记(68)——nginx缓存配置及其他配置
下一篇: PHP数组奇怪的有关问题