编程爱好者之家
$arr2 = array( 0=>array( "name" => "编程爱好者之家", "total" => 80, "num" => 3 ), 1=>array( "name" => "编程爱好者之家", "total" => 3, "num" => 1 ), 2=>array( "name" => "测试", "total" => 100, "num" => 88 ), ); $item=array(); foreach($arr2 as $k=>$v){ if(!isset($item[$v['name']])){ $item[$v['name']]=$v; }else{ $item[$v['name']]['total']+=$v['total']; $item[$v['name']]['num']+=$v['num']; } } print_r($item);
输出结果如下