php 递归数据,三维数组转换二维

时间:2024-09-30 16:06:56
 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;
}
}