tp商城(4)

//

TP==shop


// 获取栏目树
public function getTree($parent_id=0 , $lev=0) {
    $tree = array();

    foreach($this->cats as $c) {
        if($c['parent_id'] == $parent_id) {
            $c['lev'] = $lev;
            $tree[] = $c;

            // 再查$c的下级栏目
            $tree = array_merge($tree , $this->getTree($c['cat_id'] , $lev+1) );
        }
    }

    return $tree;
}

你可能感兴趣的:(tp商城(4))