时间:2021-07-01 10:21:17 帮助过:26人阅读
Array
(
[Category] => TOTAL
[January2014_Number_stores] => 0
[February2014_Number_stores] => 0
[March2014_Number_stores] => 0
)
Array
(
[January2014_Number_stores] => 155
[February2014_Number_stores] => 155
[March2014_Number_stores] => 155
)
Array
(
[January2014_Number_stores] => 126
[February2014_Number_stores] => 126
[March2014_Number_stores] => 126
)
Array
(
[January2014_Number_stores] => 37
[February2014_Number_stores] => 37
[March2014_Number_stores] => 37
)
Array
(
[January2014_Number_stores] => 9
[February2014_Number_stores] => 9
[March2014_Number_stores] => 9
)
Array
(
[January2014_Number_stores] => 4
[February2014_Number_stores] => 4
[March2014_Number_stores] => 4
)
$a = array(Array
'Category' => 'TOTAL',
'January2014_Number_stores' => 0,
'February2014_Number_stores' => 0,
'March2014_Number_stores' => 0,
);
$b = array(
array(
'January2014_Number_stores' => 155,
'February2014_Number_stores' => 155,
'March2014_Number_stores' => 155,
),
array(
'January2014_Number_stores' => 126,
'February2014_Number_stores' => 126,
'March2014_Number_stores' => 126,
),
array(
'January2014_Number_stores' => 37,
'February2014_Number_stores' => 37,
'March2014_Number_stores' => 37,
),
array(
'January2014_Number_stores' => 9,
'February2014_Number_stores' => 9,
'March2014_Number_stores' => 9,
),
array(
'January2014_Number_stores' => 4,
'February2014_Number_stores' => 4,
'March2014_Number_stores' => 4,
),
);
foreach($b as $r) {
foreach($r as $k=>$v) {
if(! isset($a[$k])) $a[$k] = 0;
$a[$k] += $v;
}
}
print_r($a);