PHP递归方法

public function catSort($arr,$pid=0,$lev=0) {

        foreach($arr as $v) {

            if($v['parent_id'] == $pid) {

                $v['lev'] = $lev;

                $this->cateList[] = $v;

                $this->catSort($arr,$v['cat_id'],$lev+1);

            }

        }

    }

原文地址:https://www.cnblogs.com/Ares0023/p/10129664.html