多层级栏目lst输出方式

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_27905477/article/details/78144272

多级栏目分类或者多级栏目,区别层级栏目可用以下THINKPHP代码

public function pritree()

{
$data=$this->select();
return $this->resort($data);
}


public function resort($data,$parentid=0,$level=0)
{
static $ret=array();
foreach ($data as $k => $v) 
{
if($v['parentid']==$parentid)
{
$v['level']=$level;
$ret[]=$v;
$this->resort($data,$v['id'],$level+1);
}
}


return $ret;


}

猜你喜欢

转载自blog.csdn.net/qq_27905477/article/details/78144272
0条评论
添加一条新回复