- 调用模型
$cate = new CateModel(); $res = $cate->catetree();
- 模型实现递归
public function catetree() { $cateres = $this->select(); return $this->sort($cateres); } public function sort($data,$pid=0,$level=0) { static $arr = array(); foreach ($data as $key => $v) { if($v['pid'] == $pid){ $v['level'] = $level; $arr[] = $v; $this->sort($data,$v['id'],$level+1); } } return $arr; }
3.视图输出
<!-- 表格显示 --> {volist name = "res" id = "vo"} <tr> <td align="center">{$vo.id}</td> <td align="left"><?php echo
tp5无限极分类
最新推荐文章于 2022-03-28 15:17:05 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)