Title:用递归的方法实现无限极分类Create:2018-09-05 ◊ 访问量:501

UpDate:2018-09-05 02:15
Author: TabKey9 点赞:0  评论:0


#递归方法实现无限极分类
function getTree($list,$pid=0,$level=0) {
    static $tree = array();
    foreach($list as $row) {
        if($row['pid']==$pid) {
            $row['level'] = $level;
            $tree[] = $row;
            getTree($list, $row['id'], $level + 1);
        }
    }
    return $tree;
}