您的位置:首页 > 编程语言 > PHP开发

thinkphp数组分页

2020-06-08 05:41 435 查看
1 前几天做项目,用到thinkphp数组分页,现将代码记录如下:
2
3 public function arrayPaging($list)
4
5 {
6
7 //定义每页显示数
8
9 $per=10;
10
11 //得到数组总数
12
13 $count=count($list);
14
15 //创建分页对象
16
17 $page=new \Think\Page($count,$per);
18
19 //利用array_slice函数分页
20
21 $list=arrayslice($list,$page−>firstRow,$page->lastRows);
22
23 //分页显示输出
24
25 $show=$page->show();
26
27 //给模板赋值并输出
28
29 $this−>assign(′per′,$per);
30
31 $this−>assign(′count′,$count);
32
33 $this−>assign(′page′,$show);
34
35 $this−>assing(′list′,$list);
36
37 $this->display();
38
39 }

 

转载于:https://www.cnblogs.com/zjl10101314/articles/9384625.html

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: