PHP引用

来源:互联网 发布:php社交网站 编辑:程序博客网 时间:2024/05/17 00:13
public function dataInit($rows, $id='id',$pid = 'pid',$child = 'child',$root=0){     $tree = array();    if(is_array($rows))    {        $array = array();        foreach($rows as $key=>$item)        {            $array[$item[$id]] =& $rows[$key];        }        foreach($rows as $key=>$item)        {            $parentId = $item[$pid];            if($root == $parentId){                $tree[] =& $rows[$key];            }else{                if(isset($array[$parentId])){                    $parent =& $array[$parentId];                    $parent[$child][] =& $rows[$key];                }            }           }    }    return $tree;}
原创粉丝点击