时间:2021-07-01 10:21:17 帮助过:8人阅读
Array(
[0] => Array (
[log_data] => 4
[log_result] => 0
[log_time] => 2013-05-08 10:08:40 )
[1] => Array (
[log_data] => 10018
[log_result] => 2
[log_time] => 2013-05-08 10:13:58 )
[2] => Array (
[log_data] => 10018
[log_result] => 2
[log_time] => 2013-05-08 10:14:02 )
[3] => Array (
[log_data] => 10003
[log_result] => 50
[log_time] => 2013-05-08 10:18:29 )
)
$ar = Array(
Array (
'log_data' => 4,
'log_result' => 0,
'log_time' => '2013-05-08 10:08:40'
),
Array (
'log_data' => 10018,
'log_result' => 2,
'log_time' => '2013-05-08 10:13:58',
),
Array (
'log_data' => 10018,
'log_result' => 2,
'log_time' => '2013-05-08 10:14:02',
),
Array (
'log_data' => 10003,
'log_result' => 50,
'log_time' => '2013-05-08 10:18:29',
),
);
foreach($ar as $item) {
@$res[$item['log_data']][strtok($item['log_time'], ' ')] += $item['log_result'];
}
print_r($res);
Array
(
[4] => Array
(
[2013-05-08] => 0
)
[10018] => Array
(
[2013-05-08] => 4
)
[10003] => Array
(
[2013-05-08] => 50
)
)
$ar = Array(
Array (
'log_data' => 4,
'log_result' => 0,
'log_time' => '2013-05-08 10:08:40'
),
Array (
'log_data' => 10018,
'log_result' => 2,
'log_time' => '2013-05-08 10:13:58',
),
Array (
'log_data' => 10018,
'log_result' => 2,
'log_time' => '2013-05-08 10:14:02',
),
Array (
'log_data' => 10003,