Heim >Backend-Entwicklung >PHP-Tutorial >关于thinkPHP3.2的无限遍历问题,困扰了几天了
先贴图和代码------------
无限递归函数--
/** * 无限递归 * @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;}
thinkPHP3.2递归
thinkPHP3.2递归
thinkPHP3.2递归
大大,这是什么意思