博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PHP无限级分类,三级联动,三级菜单,递归
阅读量:4299 次
发布时间:2019-05-27

本文共 836 字,大约阅读时间需要 2 分钟。

if (!function_exists('get_cate_list')) {
//递归函数 实现无限级分类列表 function get_cate_list($list,$pid=0,$level=0) {
static $tree = array(); foreach($list as $row) {
if($row['pid']==$pid) {
$row['level'] = $level; $tree[] = $row; get_cate_list($list, $row['id'], $level + 1); } } return $tree; }}if(!function_exists('get_tree_list')){
//引用方式实现 父子级树状结构 function get_tree_list($list){
//将每条数据中的id值作为其下标 $temp = []; foreach($list as $v){
$v['son'] = []; $temp[$v['id']] = $v; } //获取分类树 foreach($temp as $k=>$v){
$temp[$v['pid']]['son'][] = &$temp[$v['id']]; } return isset($temp[0]['son']) ? $temp[0]['son'] : []; }}

转载地址:http://ehiws.baihongyu.com/

你可能感兴趣的文章
登录式shell的执行顺序及简单应用
查看>>
屏蔽搜索引擎蜘蛛的代码
查看>>
查阅日志小技巧
查看>>
mac iterm2有什么酷功能?
查看>>
django 改写models 的save操作。
查看>>
用redis的sadd和spop做后台抽奖
查看>>
redis学习笔记之数据类型
查看>>
简谈微服务
查看>>
CAP定理
查看>>
Centos7 初试docker
查看>>
Dockerfile
查看>>
分析html利器--Beautiful Soup
查看>>
python 有序字典OrderedDict
查看>>
redis 执行filter 过滤
查看>>
centos7 安装 mariadb(mysql的一个分支) 的正确命令
查看>>
简谈python hashlib
查看>>
git的patch(打包)功能
查看>>
django QuerySet对象转换成字典对象
查看>>
入门python(1)
查看>>
入门python-异常(2)
查看>>