This article mainly introduces php's simple method of implementing array paging, involving php array operations and mathematical operations related skills, for more information about how to implement array paging in php, see the example in this article. We will share this with you for your reference. The details are as follows:
First, read the manual to learn more.
Php built-in functions can solve some difficult problems.
<? Php/*** Created by JetBrains PhpStorm. * User: Administrator * Date: 13-6-11 * Time: 11 am * To change this template use File | Settings | File Templates. */header ("Content-type: text/html; charset = utf-8"); $ array = array,, 20, 21, 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 "$ val \ n";} echo"
"; Echo" First Page \ n "; $ str =''; for ($ I = 1; $ I <= $ pnum-1; $ I ++) {echo "$ I \ n";} echo "Last Page \ n";?>