Php uses the array function to implement paging. phparray function paging. Php uses the array function to implement paging. The paging code of the phparray function is very simple, so there is not much nonsense. Copy the code as follows: $ arrayarray (, 1 php uses the array function to implement paging, phparray function paging
The code is very simple, so there is not much nonsense.
The code is as follows:
$ Array = array ("1", "2", "3", "4", "5", "6", "7", "8 ", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18 ", "19", "20"); // specifies the array to be paged
$ Page = $ _ GET ['Page'];
$ R = $ this-> page ($ array, 5, $ page );
Print_r ($ r );
Exit ();
Foreach ($ r ["source"] as $ s ){
Echo $ s;
}
Function page ($ array, $ pagesize, $ current ){
$ _ Return = array ();
$ Total = ceil (Count ($ array)/$ pagesize); // calculates the total number of pages
$ Prev = ($ current-1) <= 0? "1" :( $ current-1); // confirm the previous page. if the current page is the first page, click to display the first page.
$ Next = ($ current + 1) >=$ total? $ Total: $ current + 1); // confirm the next page. if the current page is the last page, click the next page to display the last page.
$ Current = ($ current> ($ total )? ($ Total): $ current); // if the current page is greater than the total page number, the current page is the last page
$ Start = ($ current-1) * $ pagesize; // The number of items that should be read from the page.
For ($ I = $ start; $ I <($ start + $ pagesize); $ I ++ ){
Array_push ($ _ return, $ array [$ I]); // put the displayed information into the array $ _ return
}
$ Pagearray ["source"] =$ _ return;
$ Pagearray ["page"] = "first \"> prev next end "; // The page style can be adjusted as needed
Return $ pagearray;
}
The above is the core code that uses the array function to implement paging. I hope you will like it.
The http://www.bkjia.com/PHPjc/958256.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/958256.htmlTechArticlephp uses the array function to implement paging, phparray function paging code is very simple, not much nonsense. The code is as follows: $ array = array ("1", "2", "3", "4", "5", "6", "7", "8 ", "9", "10", "1...