根据首字母进行排序


public function getList($data,$user) {
$list = \app\common\model\ChinaArea::getCityList();
$province = \app\common\model\ChinaArea::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);
}

 

posted @ 2021-03-09 10:13  zlf2000  阅读(162)  评论(0编辑  收藏  举报