<?php
$a= array(
array(
'ID'=> 2
)
);
$b= array(
array(
'ID'=> 5656
)
);
print_r($r);
//合并两个数组 以ID值 作为键
function mergeById(&$arr1,&$arr2, $key='ID')
{
$arr = array();
foreach($arr1 as $v) {
$arr[$v[$key]] = $v;
}
foreach($arr2 as $v){
$arr[$v[$key]] = isset($arr[$v[$key]])? $arr[$v[$key]]+$v : $v;
}
return $arr;
}
print_r(mergeById($a,$b,'ID'));
Array
(
[2] => Array
(
[ID] => 2
)
[5656] => Array
(
[ID] => 5656
)
)
?>