The example in this article describes how to simply implement array paging in PHP. Share it with everyone for your reference, the details are as follows:
First learn things and read more manuals
Use the functions that come with PHP to solve some difficult problems
<?php /** * Created by JetBrains PhpStorm. * User: Administrator * Date: 13-6-11 * Time: 上午11:43 * To change this template use File | Settings | File Templates. */ header("Content-type:text/html;charset=utf-8"); $array =array (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24,25); $page=$_GET['page']?(int)$_GET['page']:'0'; $size=5; $pnum = ceil(count($array) / $size); $newArray = array_slice($array,($page-1)*$size,$size); foreach($newArray as $key=>$val) { echo "<a href=\"array1.php?catid=$key.html\" target=\"_blank\">$val</a>\n"; } echo "<br/><br/><br/><br/>"; echo "<a href=?>第一页</a>\n"; $str=''; for($i=1;$i<=$pnum-1;$i++) { echo "<a href=\"?page=$i\" target=\"_blank\""; if($i==$page){echo "style='color:red;'";}; echo ">$i</a>\n\n"; } echo "<a href=?page=$pnum>最后一页</a>\n"; ?>
Readers who are interested in more PHP-related content can check it out Special topics on this site: "Complete PHP Array (Array) Operation Skills", "Summary of PHP Regular Expression Usage", "Summary of PHP+ajax Skills and Applications", "Summary of PHP Operations and Operator Usage", "Summary of PHP Network Programming Skills" ", "Introduction Tutorial on PHP Basic Syntax", "Summary of PHP Office Document Skills (Including Word, Excel, Access, PPT)", "Summary of PHP Date and Time Usage", "Introduction Tutorial on PHP Object-Oriented Programming", "php "Summary of String Usage", "Introduction Tutorial on PHP+MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"
I hope this article will be helpful to everyone in PHP programming.
The above introduces the simple method of implementing array paging in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.