First, learn more and read the handbook.
Using PHP's own functions can solve some difficult problems
<?php/** * Created by JetBrains Phpstorm. * User:administrator * date:13-6-11 * Time: Morning 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, $ ($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=?> first page </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 > last page </a>\n";? >
PHP implementation paging, previous page next page