无限极分类生成
浏览量:384
public function getCateTree() { $list = []; $data = $this->select(); $list = $this->getTree($data); return $list; } public function getTree($data,$id=0,$level=1) { static $list = []; foreach($data as $key => $value){ if($value['parent_id'] == $id){ $value['level'] = $level; $list[] = $value; //$this->getTree($data); /*foreach($data as $k=>$v){ if($v['parent_id'] == $value['id']){ $list[] = $v; } }*/ $this->getTree($data,$value['id'],$level+1); } } return $list; }