: Php array paging implementation method: This article describes how to implement php array paging. For your reference, see 3. clickDate & gt; 2010-10-11), array (clicks & gt; 2, clickDate & gt; 2010-10-10), array (clicks & gt; 3. clickDate & gt; 201 This article describes the php array paging implementation method. We will share this with you for your reference. The details are as follows:
<? Php $ arr_click = array ('clicks' => 3, 'clickdate' => '2017-10-11 '), array ('clicks' => 2, 'clickdate' => '2017-10-10 '), array ('clicks' => 3, 'clickdate' => '2017-10-09 '), array ('clicks' => 4, 'clickdate' => '2017-10-08 '), array ('clicks' => 5, 'clickdate' => '2017-10-13 '), array ('clicks' => 7, 'clickdate' => '2017-10-14 '), array ('clicks' => 6, 'clickdate' => '2017-10-15 '), array ('clicks' => 9, 'Clickdate' => '2017-10-16 '),); if (! Isset ($ _ GET ['Page']) {$ page = 1 ;}else {$ page =$ _ GET ['Page'] ;}$ size = 3; // number of records displayed per page $ pnum = ceil (count ($ arr_click)/$ size); // total number of pages, ceil () the function is used to evaluate the smallest integer greater than the number. // use the array_slice (array, offset, length) function to retrieve a value in the array according to the conditions. array (array ), offset (starting position of the element), length (group length) $ newarr = array_slice ($ arr_click, ($ page-1) * $ size, $ size ); for ($ I = 0; $ I
";}?> <? Phpif (! Isset ($ _ GET ['Page']) | $ _ GET ['Page'] <= 1) {?> Previous Page <? Php} else {?> "> Previous Page <? Php }?> <? Php if ($ _ GET ['Page'] >=$ pnum) {?> "> Next page <? Php} else {?> "> Next page <? Php }?>