PHP code example of kgilden / pager
1. Go to this page and download the library: Download kgilden/pager 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/ */
kgilden / pager example snippets
use KG\Pager\Pager;
use KG\Pager\Adapter\ArrayAdapter;
$list = ['apple', 'banana', 'cucumber', 'dragonfruit', 'eggplant'];
$itemsPerPage = 2;
$currentPage = 3;
$pager = new Pager();
$page = $pager->paginate(new ArrayAdapter($list), $itemsPerPage, $currentPage);
$page->isFirst(); // false
$page->isLast(); // true - there's a total of 3 pages
$page->getNumber(); // 3 - it's $currentPage
count($page->getItems()); // 1
$page->getItems(); // ["eggplant"]