关于thinkPHP3.2的无限遍历问题,困扰了几天了
先贴图和代码------------
无限递归函数--
/**<br /> * 无限递归<br /> * @param $data<br /> * @param $pId<br /> * @return array<br /> * @author 郑景强<br /> */<br />function getTree($data, $pId = 0){<br /> $tree = array();<br /> foreach($data as $k => $v){<br /> if($v['pid'] == $pId){<br /> //父亲找到儿子<br /> $v['children'] = getTree($data, $v['id']);<br /> $tree[] = $v;<br /> //unset($data[$k]);<br /> }<br /> }<br /> return $tree;<br />}<br />