多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
```php /** * 获取分类函数 */ function getTree($list,$type='1',$pid=0,$level=0){ $return = []; if($type=='1'){ foreach ($list as $k => $v) { //这里要根据数组中实际的键对应起来 if($v['pid']==$pid){ $return[$k] = $v; //这里要根据数组中实际的键对应起来 $return[$k]['title'] = str_repeat(' ├ ',$level).$v['title']; $return[$k]['child'] = getTree($list,'1',$v['id'],$level+1); } unset($list[$k]); } }else{ foreach ($list as $k => $v) { if($v['pid']==$pid){ //这里要根据数组中实际的键对应起来 $return[$v['id']] = $v; //这里要根据数组中实际的键对应起来 $return[$v['id']]['title'] = str_repeat('├ ',$level).$v['title']; $return = $return+ getTree($list,'2',$v['id'],$level+1); } unset($list[$k]); } } return $return; } ```