獲取當前分類下面的子分類

// 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; }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章