Utility to generate an intelligent "range" of links based on the current page and total pages.
Install via composer into your project:
composer require anekdotes/pagination
Instantiate the class and use the pager method with a few parameters.
-
$pages: total number of pages
-
$current: current page
-
$length (optional): how many page to display
use Anekdotes\Pagination\Pagination;
$pagination = new Pagination();
var_dump($pagination->pager(10, 1));
/*
array(6) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
[4]=>
int(5)
[5]=>
int(6)
}
*/