当前位置 : 主页 > 网络编程 > PHP >

tree.php

来源:互联网 收集:自由互联 发布时间:2021-06-28
tree.php public function list_level($arr,$pid=0,$lev=0){ $data = array(); foreach($arr as $k=$v){ if($v['pid'] == $pid){ $v['level'] = $lev; $data[] = $v; $data=array_merge($data,$this-list_level($arr,$v['id'],$lev+1)); } } return $data; }
tree.php
public function list_level($arr,$pid=0,$lev=0){
        $data = array();
        foreach($arr as $k=>$v){
            if($v['pid'] == $pid){
                $v['level'] = $lev;
                $data[] = $v;
                $data=array_merge($data,$this->list_level($arr,$v['id'],$lev+1));
            }
        }
        return $data;
    }
网友评论