1. 程式人生 > >遞迴無限極分類

遞迴無限極分類

//公共函式
function _getchildren($data,$pid = 0,$level = 0)
{

    static $tree = array();

    foreach($data as $vo){

        if($vo['parent_id'] == $pid){

            $vo['level'] = $level;
            $tree[] = $vo;
            $this->_getChildren($data,$vo['ID'],$level+ 1);
        }
    }
    return $tree;
}