thinkphp 下多个数组组合分页
1、假如有多个数组的情况下,又想在前端分页展示,用tp5自带的paginate 和 each 方式,个人觉得很麻烦;例如:
$result=array_merge($assemble,$disassembly,$picking,$returnpicking,$overstock,$invtransfer);
2、可以使用以下方式解决
$count=count($result);$p=getpage($count,$this->limitRow);//getpage()方法$curpage=$this->request->param("p")?$this->request->param("p"):1;//当前第x页,有效值为:1,2,3,4,5...if($curpage==1){$firstrow=0;}else{$firstrow=($curpage-1)*$this->limitRow;}$list=array_slice($result,$firstrow,$this->limitRow);//$this->limitRow是分页条数,请自己设置$this->assign("result",$list);$this->assign('page',$p->show());//此方法最好写到公共函数库里,方便其他地方也可以调用,避免代码重写functiongetpage($count,$pagesize=10){$p=newPage($count,$pagesize);//thinkphp自带的page分页类//$p->setConfig('header','<liclass="rows">共<b>%TOTAL_ROW%</b>条记录第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>');$p->setConfig('prev','上一页');$p->setConfig('next','下一页');$p->setConfig('last','末页');$p->setConfig('first','首页');//$p->setConfig('theme','%FIRST%%UP_PAGE%%LINK_PAGE%%DOWN_PAGE%%END%%HEADER%');$p->lastSuffix=false;//最后一页不显示为总页数return$p;}
3、如果有用,请收藏,谢谢~~~
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。