thinkphp 无限级分类

来源:互联网 发布:数据库密码忘了怎么办 编辑:程序博客网 时间:2024/06/05 17:11
 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


原创粉丝点击