php 一个三维数组,把值相同的合并,并把其它值累加
Array([0]=>Array([0]=>Array([idc_name_list]=>韩国电信[start_time]=>2014-09-0412:10[end_ti...
Array
(
[0] => Array
(
[0] => Array
(
[idc_name_list] => 韩国电信
[start_time] => 2014-09-04 12:10
[end_time] => 2014-09-04 12:10
[online_down] => 0
)
)
[1] => Array
(
[0] => Array
(
[idc_name_list] => 首都在线云
[online_down] => 23
[start_time] => 2014-11-20 17:49
[end_time] => 2014-11-20 17:49
)
)
[2] => Array
(
[0] => Array
(
[idc_name_list] => 电信通苏州桥
[online_down] => 153
[start_time] => 2014-07-23 14:50
[end_time] => 2014-07-31 14:50
)
)
[4] => Array
(
[0] => Array
(
[idc_name_list] => 电信通苏州桥
[online_down] => 200
[start_time] => 2014-08-02 11:08
[end_time] => 2014-08-02 13:08
)
)
) 展开
(
[0] => Array
(
[0] => Array
(
[idc_name_list] => 韩国电信
[start_time] => 2014-09-04 12:10
[end_time] => 2014-09-04 12:10
[online_down] => 0
)
)
[1] => Array
(
[0] => Array
(
[idc_name_list] => 首都在线云
[online_down] => 23
[start_time] => 2014-11-20 17:49
[end_time] => 2014-11-20 17:49
)
)
[2] => Array
(
[0] => Array
(
[idc_name_list] => 电信通苏州桥
[online_down] => 153
[start_time] => 2014-07-23 14:50
[end_time] => 2014-07-31 14:50
)
)
[4] => Array
(
[0] => Array
(
[idc_name_list] => 电信通苏州桥
[online_down] => 200
[start_time] => 2014-08-02 11:08
[end_time] => 2014-08-02 13:08
)
)
) 展开
3个回答
推荐于2016-11-11
展开全部
$arr=array
(
0 => array
(
0 => array
(
'idc_name_list' => '韩国电信',
'start_time' => '2014-09-04 12:10',
'end_time' => '2014-09-04 12:10',
'online_down' => 0
)
),
1 => Array
(
0 => array
(
'idc_name_list' => '首都在线云',
'online_down' => 23,
'start_time' => '2014-11-20 17:49',
'end_time' => '2014-11-20 17:49'
)
),
2 => array
(
0 => Array
(
'idc_name_list' => '电信通苏州桥',
'online_down' => 153,
'start_time' => '2014-07-23 14:50',
'end_time' => '2014-07-31 14:50'
)
),
4 => Array
(
0 => Array
(
'idc_name_list' => '电信通苏州桥',
'online_down' => 200,
'start_time' => '2014-08-02 11:08',
'end_time' => '2014-08-02 13:08'
)
)
);
$item=array();
foreach($arr as $key=>$value){
foreach($value as $k=>$v){
if(!isset($item[$v['idc_name_list']])){
$item[$v['idc_name_list']]=$v;
}else{
$item[$v['idc_name_list']]['online_down'].=','.$v['online_down'];
$item[$v['idc_name_list']]['start_time'].=','.$v['start_time'];
$item[$v['idc_name_list']]['end_time'].=','.$v['end_time'];
}
}
}
print_r($item);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询