class CatModel extends Model{
public function gettree($p=0,$lv=0){
$t=array();
foreach($this->select()as $k=>$v){
if($v['parent_id']==$p){
$v['lv']=$lv;
$t[]=$v;
$t=array_merge($t,$this->gettree($v['cat_id'],$lv+1));//合并数组
}
}
return $t;
}
}
html表单中的左边距也要相应变化
style="margin-left:{$cat['lv']*2}em