array(3) {
[0]=>
array(2) {
["sourcesid"]=>
int(1)
["addusernum"]=>
string(1) "4"
}
[1]=>
array(2) {
["sourcesid"]=>
int(6)
["addusernum"]=>
string(2) "29"
}
[2]=>
array(2) {
["sourcesid"]=>
string(1) "6"
["addusernum"]=>
string(2) "63"
}
}
解决方案: foreach($sourceData as $k=>$v){ if(!isset($item[$v['sourcesid']])){ $item[$v['sourcesid']]=$v; }else{ $item[$v['sourcesid']]['addusernum']+=$v['addusernum']; } }