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
相关资源:thinkphp实现数组分页示例
转载请注明原文地址: https://mac.8miu.com/read-78193.html