PHP code example of alexkratky / paginationx

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

    

alexkratky / paginationx example snippets



use AlexKratky\Pagination;

//example data
$data = array(0,1,2,3,4,5,6,7,8,9);
//enter data and how many elements are on page (3). By default 10.
$pagination = new Pagination($data, 3);
$d = $pagination->getData(); // [0,1,2]
$pagination->currentPage(); // 1
$pagination->totalPages(); // 4 (floor(10/3)+1)
$pagination->previousPage(); // false; because the first page is the lowest one
$pagination->nextPage(); // 2