class treeClass{
//pid父id
//$arr无限分类数组
public function tree($pid,$arr){
$tree = array_filter($arr,function($v) use($pid){return $v['parent_id'] == $pid;
});
if(!empty($tree)){
foreach ($tree as $k=>$v){
$son = $this->tree($v['id'], $arr);
if(!empty($son)){
if(isset($tree[$k]['son'])){
$tree[$k]['son'] = array_merge($son,$tree[$k]['son']);
}else{
$tree[$k]['son'] = $son;
}
}
}
}
return $tree;
}
}