$ar = array(
557 => array(
'ComponentItem' => '541-0089-23',
'2007-04-11' => 1,
'2007-04-23' => 1,
'2007-05-11' => 2,
'2007-05-29' => 3,
'2007-06-01' => 4,
),
562 => array(
'ComponentItem' => '036-0616-00',
'2007-04-13' => 3,
'2007-05-13' => 4,
'2007-05-17' => 5,
'2007-06-22' => 6,
),
);function foo($t) {
foreach($t as $k=>$v) {
if(strtotime($k) > 0) {
$r[date('m', strtotime($k))] += $v;
}else {
$r[$k] = $v;
}
}
return $r;
}$o = array_map('foo', $ar);
print_r($o);
557 => array(
'ComponentItem' => '541-0089-23',
'2007-04-11' => 1,
'2007-04-23' => 1,
'2007-05-11' => 2,
'2007-05-29' => 3,
'2007-06-01' => 4,
),
562 => array(
'ComponentItem' => '036-0616-00',
'2007-04-13' => 3,
'2007-05-13' => 4,
'2007-05-17' => 5,
'2007-06-22' => 6,
),
);function foo($t) {
foreach($t as $k=>$v) {
if(strtotime($k) > 0) {
$r[date('m', strtotime($k))] += $v;
}else {
$r[$k] = $v;
}
}
return $r;
}$o = array_map('foo', $ar);
print_r($o);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货