Home >Backend Development >PHP Tutorial >参照数组合并-php 二维数组合并 以一个数组为参照,比它多的项删除,比它少的项增加,相同的增加

参照数组合并-php 二维数组合并 以一个数组为参照,比它多的项删除,比它少的项增加,相同的增加

WBOY
WBOYOriginal
2016-06-02 11:34:44971browse

参照数组合并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 )
请教下大家,

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