public function getTree($category){
//排序 存放最终排完序的分类数据
$arr = [];
//先获取一类
foreach ($category as $k => $) {
//一级类
if ($v->cate_pid == 0) {
$arr[] = $v;
//获取一级类下的二级类
foreach ($category as $m => $n) {
if($v -> cate_id == $n->cate_pid){
//给分类名称添加缩进
$n->cate_name = '|-------' . $n->cate_name;
$arr[] = $n;
}
}
}
}
}
分类列表具有层级显示效果方法
最新推荐文章于 2024-07-12 23:03:07 发布