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; }
原文地址:http://itafei.blog.51cto.com/10862892/1949755