数据表结构

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;
    }

 

相关文章:

  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2022-03-01
  • 2021-08-19
  • 2021-11-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2022-02-09
相关资源
相似解决方案