function getTree($items) { foreach($items as $value){ $value[‘son‘] =array(); $new_address[$value[‘id‘]] = $value; } foreach($new_address as &$value){ if($value[‘pid‘] !=0){ $new_address[$value[‘pid‘]][‘son‘][] = &$value; }else{ $res_address[$value[‘id‘]] = &$value; } } return $res_address; }
时间: 2024-10-07 05:22:21