1. 程式人生 > >php 遞歸數據,三維數組轉換二維

php 遞歸數據,三維數組轉換二維

tar nbsp 數組 return _id arr ati this for

 public function sortarea($area, $parent_id = 0, $lev = 1){
        static $list;
        foreach($area as $v){
            if($v[‘upid‘] == $parent_id){
                $v[‘lev‘] = $lev;
                $list[] = $v;
                $this->sortarea($area,$v[‘cid‘],$lev+1);
            }
        }
        
return $list; }
$newArr = array(); foreach($Res as $key=>$val){ foreach($val as $k=>$v){ $newArr[] = $v; } }

php 遞歸數據,三維數組轉換二維