public function getTrees($arr,$pid,$step = 0){
global $tree;
foreach($arr as $val) {
if($val['parent_id'] == $pid) {
$flag = str_repeat('-----------',$step);
$val['cat_name'] = $flag.$val['cat_name'];
$tree[] = $val;
$this->getTrees($arr , $val['id'] ,$step+1);
}
}
return $tree;
}
$this->getTrees($result, 0, 0);
网友评论