Last Updated: February 25, 2016
· gosukiwi

PHP Pagination Generator

I find this class to be quite useful:

Basically, it generates an unordered list ul with links to several pages, it's pretty cusomizable, it can output bootstrap style pagination markup, purecss markup, or any custom markup!

Here are some usage examples:

Generate PureCSS markup

$paginator = new Paginator();
$pagination = $paginator
    ->total(135)                // total items to paginate
    ->per_page(10)              // how many to show per page
    ->page_name('p')            // ?p=1
    ->ul_class('pure-paginator')    // css styles

Generate Bootstraps markup

$paginator = new Paginator();
$pagination = $paginator
    ->ul_class('pagination') // bootstraps only requires this