参照数组合并-php 二维数组合并 以一个数组为参照,比它多的项删除,比它少的项增加,相同的增加
程序员文章站
2022-05-25 10:19:06
...
参照数组合并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 )
请教下大家,
上一篇: 索引分析和优化解决方案_MySQL
下一篇: PHP 设置MySQL连接字符集的方法