数据表结构
id | name | pid |
private function tree($data,$p_id=){
foreach($data as $row){
if($row['pid']==$p_id){
$tmp = $this->tree($data,$row['id']);
if($tmp){
$row['child']=$tmp;
}else{
$row['leaf'] = true;
}
$tree[]=$row;
}
}
Return $tree;
}
2023-07-21 20:56:58
数据表结构
id | name | pid |
private function tree($data,$p_id=){
foreach($data as $row){
if($row['pid']==$p_id){
$tmp = $this->tree($data,$row['id']);
if($tmp){
$row['child']=$tmp;
}else{
$row['leaf'] = true;
}
$tree[]=$row;
}
}
Return $tree;
}