编程语言
首页 > 编程语言> > php按数组中的时间字段分组

php按数组中的时间字段分组

作者:互联网

$data = $db->select('am_table_main', '*',['ORDER'=>['added_time'=>'DESC']]);

$new_data = [];
foreach($data as $key => &$val){
	$val['month'] = mb_substr($val['added_time'], 0 ,7);
	$new_data[$val['month']][] = $val;
}
unset($val);

标签:added,val,month,分组,数组,time,new,php,data
来源: https://blog.csdn.net/qq_39034363/article/details/114837154