数据表结构
id | name | pid |
private function tree($data,$p_id=0){ 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; }
本文共 410 字,大约阅读时间需要 1 分钟。
数据表结构
id | name | pid |
private function tree($data,$p_id=0){ 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; }
转载地址:http://acgpa.baihongyu.com/