简单的无限分类树
public function tree2($arr,$pid)
{
$html = '';
foreach($arr as $k => $v)
{
if($v['pid'] == $pid)
{ //父亲找到儿子
$html = $html."<li>";
$html .= $v['id'];
$html .= $v['username'];
$html = $html."</li>";
$html .= $this->tree2($arr, $v['id']);
}
}
return $html ? '<ul>'.$html.'</ul>' : $html ;
}