Home  >  Article  >  php教程  >  PHP基于数组实现的分页函数实例

PHP基于数组实现的分页函数实例

WBOY
WBOYOriginal
2016-06-06 20:19:131278browse

这篇文章主要介绍了PHP基于数组实现的分页函数实例,是非常实用的一个技巧,需要的朋友可以参考下

分页功能是PHP程序设计中非常常见的功能,不同于以往的,今天本文介绍的是PHP基于数组实现的分页函数。

关于数组的分页函数,用数组进行分页的好处是可以方便的进行联合多表查询,只需要将查询的结果放在数组中就可以了以下是数组分页的函数,函数page_array用于数组的分页,函数show_array用于分页函数的操作及显示,需要配合使用。两个函数通过全局变量$countpage发生联系,此变量用于跟踪总页码数。

具体实例代码如下:

1){ $uppage=$page-1; }else{ $uppage=1; } if($page '; $str.="共 {$countpage} 页 / 第 {$page} 页"; $str.=" 首页 "; $str.=" 上一页 "; $str.="下一页 "; $str.="尾页 "; $str.=''; return $str; } ?>

希望本文所述实例对大家的PHP程序设计能起到一定的借鉴作用。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn