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;
}

  具体的还是还要读懂其中的含义

posted @ 2018-01-05 14:10  怪咖在骚动  阅读(315)  评论(0编辑  收藏  举报