PHP项目中经常用到的无限极分类函数
//无限极分类函数调用 function getTree($data,$parent_id = 0,$dept_level = 0){ static $tree = []; foreach ($data as $row){ if($row['dept_pid'] == $parent_id){ $row['dept_level'] = $dept_level; $tree[] = $row; getTree($data,$row['dept_id'],$dept_level+1); } } return $tree; }
具体的还是还要读懂其中的含义