PHP 无限级分类

xiaoxiao2021-02-28  104

private function actionGettree($arr,$pid,$step){     global $tree;     foreach($arr as $key=>$val) {         if($val['parent_id'] == $pid) {             $flg = str_repeat('└―',$step);             $val['lm_name'] = $flg.$val['lm_name'];             $tree[] = $val;             $this->actionGettree($arr , $val['id'] ,$step+1);         }     }     return $tree;

}

最后在另一个方法中:

$newarr = $this->actionGettree($arr, 0, 0);

这样调用就可以了

转载请注明原文地址: https://www.6miu.com/read-28293.html

最新回复(0)