PHP code example of innobrig / paginator

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

    

innobrig / paginator example snippets


    
     InnoBrig\Paginator;

    $totalItems = 1000;
    $itemsPerPage = 50;
    $currentPage = 8;
    $urlPattern = '/foo/page/(:num)';

    $paginator = new Paginator($totalItems, $itemsPerPage, $currentPage, $urlPattern);

    
 
          // Example of rendering the pagination control with the built-in template.
          // See below for information about using other templates or custom rendering.

          echo $paginator; 
        
 if ($paginator->getPrevUrl()): 
 echo $paginator->getPrevUrl(); 
 endif; 
 foreach ($paginator->getPages() as $page): 
 if ($page['url']): 
 echo $page['isCurrent'] ? 'class="active"' : ''; 
 echo $page['url']; 
 echo $page['num']; 
 else: 
 echo $page['num']; 
 endif; 
 endforeach; 
 if ($paginator->getNextUrl()): 
 echo $paginator->getNextUrl(); 
 endif; 
 echo $paginator->getTotalItems(); 
 echo $paginator->getCurrentPageFirstItem(); 
 echo $paginator->getCurrentPageLastItem();