拿时间做一个栗子:
$data = Array
(
[0] => Array
(
[user_id] => 14
[agent_id] => 2
[nickname] => 匿名
[username] => D5VCDP
[refman] =>
[refid] => 0
[promoter_id] => 0
[apply_time] => 2019-05-12 10:00:38
)
[1] => Array
(
[user_id] => 16
[agent_id] => 2
[nickname] => 匿名
[username] => 3VD4NC
[refman] => D5VCDP
[refid] => 13
[promoter_id] => 0
[apply_time] => 2019-04-12 10:05:35
)
[2] => Array
(
[user_id] => 17
[agent_id] => 2
[nickname] => 匿名
[username] => DC1MCU
[refman] => D5VCDP
[refid] => 13
[promoter_id] => 0
[apply_time] => 2019-04-12 10:05:40
)
[3] => Array
(
[user_id] => 19
[agent_id] => 2
[nickname] => 匿名
[username] => 8OJDCE
[refman] => DC1MCU
[refid] => 16
[promoter_id] => 0
[apply_time] => 2019-04-12 10:05:50
)
[4] => Array
(
[user_id] => 20
[agent_id] => 2
[nickname] => 匿名
[username] => Q71I3G
[refman] =>
[refid] => 0
[promoter_id] => 0
[apply_time] => 2019-03-12 14:19:31
)
)
$result=[];
foreach($data as $value){
$result[date('Y-m-d',strtotime($value["apply_time"]))][]=[
'user_id'=>$value['user_id'],
'agent_id'=>$value['agent_id'],
'nickname'=>$value['nickname'],
'username'=>$value['username'],
'refman' => $value['refman'],
'refid' => $value['refid'],
'promoter_id' => $value['promoter_id'],
'apply_time'=>$value['apply_time'],
];
}
print_r($result);exit;
打印结果:
Array
(
[2019-05-12] => Array
(
[0] => Array
(
[user_id] => 14
[agent_id] => 2
[nickname] => 匿名
[username] => D5VCDP
[refman] =>
[refid] => 0
[promoter_id] => 0
[apply_time] => 2019-05-12 10:00:38
)
)
[2019-04-12] => Array
(
[0] => Array
(
[user_id] => 16
[agent_id] => 2
[nickname] => 匿名
[username] => 3VD4NC
[refman] => D5VCDP
[refid] => 13
[promoter_id] => 0
[apply_time] => 2019-04-12 10:05:35
)
[1] => Array
(
[user_id] => 17
[agent_id] => 2
[nickname] => 匿名
[username] => DC1MCU
[refman] => D5VCDP
[refid] => 13
[promoter_id] => 0
[apply_time] => 2019-04-12 10:05:40
)
[2] => Array
(
[user_id] => 19
[agent_id] => 2
[nickname] => 匿名
[username] => 8OJDCE
[refman] => DC1MCU
[refid] => 16
[promoter_id] => 0
[apply_time] => 2019-04-12 10:05:50
)
)
[2019-03-12] => Array
(
[0] => Array
(
[user_id] => 20
[agent_id] => 2
[nickname] => 匿名
[username] => Q71I3G
[refman] =>
[refid] => 0
[promoter_id] => 0
[apply_time] => 2019-03-12 14:19:31
)
)
)