时间:2021-07-01 10:21:17 帮助过:6人阅读
/**
* 无限递归
* @param $data
* @param $pId
* @return array
* @author 郑景强
*/
function getTree($data, $pId = 0){
$tree = array();
foreach($data as $k => $v){
if($v['pid'] == $pId){
//父亲找到儿子
$v['children'] = getTree($data, $v['id']);
$tree[] = $v;
//unset($data[$k]);
}
}
return $tree;
}