public function tree($data,$parent_id = 0,$leave = 0) { static $tree = array(); foreach($data as $k => $v){ if($v[‘parent_id‘] == $parent_id){ $v[‘leave‘] = $leave; $tree[] = $v; $this->tree($data,$v[‘cat_id‘],$leave+1); } } return $tree; }
时间: 2024-11-07 01:08:53