/**
* 获取分类函数
*/
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;
}