PHP code example of adamlast / paginate

1. Go to this page and download the library: Download adamlast/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/ */

    

adamlast / paginate example snippets


use AdamLast\Paginate\PaginationService;

$array = ['Dingo', 'Scorpion', 'Snake', 'Shark', 'Jellyfish',
'Spider', 'Cassowary', 'Ant', 'Termite', 'Magpie',
'Kangaroo', 'Dropbear', 'Emu', 'Crocodile', 'Mosquito'];

$service = new PaginationService($array, 5);

$page = $service->getPage(2);

print ("Page ".  $page->currentPageNumber() . " of " . $page->numberOfPages(). "\n");

foreach ($page as $k => $item) {
    print("Item {$k}: {$item} \n");
}