// tree_id 为 父id //获取当前分类下的子分类(不包括自己) function get_child_tree($tree_id,$get=0) { $two_arr = []; $model = new ClassifyLogic(); $list = $model -> getList(['pid' => $tree_id], '', ''); if($get && empty($list)){ return false; } foreach ($list as $k=>$v) { $two_arr[$k]['id'] = $v['id']; $two_arr[$k]['cate_name'] = $v['cate_name']; $two_arr[$k]['pid'] = $v['pid']; $getSon = $this->get_child_tree($v['id'],1); if ($getSon){ $two_arr[$k]['child'] = $this->get_child_tree($v['id']); } } return $two_arr; }
来源:oschina
链接:https://my.oschina.net/u/3853452/blog/4320384