1. Go to this page and download the library: Download phpixie/paginate library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpixie / paginate example snippets
// Initializing
$paginate = new \PHPixie\Paginate();
// Array with a 100 items
$data = range(1, 100);
// Initialize the pager
// with 15 items per page
$pager = $paginate->arrayPager($data, 15);
// Set current page
$pager->setCurrentPager(3);
// A shorter way to do this:
$pager = $paginate->arrayPager($data, 15)
->setCurrentPage(3);
// Get some data
$pager->currentPage(); // 3
$pager->pageSize(); // 15
$pager->itemCount(); // 100
$pager->pageCount(); // 7
// Get current items
$pager->currentItems();
// Check if page exists:
$pager->pageExists(1); // true
// Check if a page exists
// relative to the current one
$this->pageOffsetExists(-1); // true
// Get page number by relative offset
// Will return null if the page is missing
// In this case 4, since 3 is the current one
$this->getPageByOffset(1);
// Some shorthands,
// also return null if page missing
$this->next(); // 4
$this->previous(); // 2