根据首字母进行排序


public function getList($data,$user) {
$list = appcommonmodelChinaArea::getCityList();
$province = appcommonmodelChinaArea::where("level",1)->cache(86400 * 7)->column("id,name");
$result = [];
foreach($list as &$val){
if($val["is_hot"]){
$result["hot"][] = $val;
}
$val["province"] = $province[$val['pid']];
读取数据库所有的首字母排序 $result["city_list"][$val['first']][] 查询的数据库必须要有一个首字母
 

$result["city_list"][$val['first']][] = $val;
}
return ApiReturn::r(1,$result);
}
原文地址:https://www.cnblogs.com/zlf2000/p/14504046.html