PHP code example of klab / php-simple-pagination

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

    

klab / php-simple-pagination example snippets



= [
    1 => ['id' => 1],
    2 => ['id' => 2],
    3 => ['id' => 3],
    4 => ['id' => 4],
    5 => ['id' => 5],
    6 => ['id' => 6],
    7 => ['id' => 7],
    8 => ['id' => 8],
    9 => ['id' => 9],
];

$items = [];
$current = (int)$_GET['page'];
$count = 3;

if ($current === 1) {
    $items = [
        $db[1],
        $db[2],
        $db[3],
        $db[4],
    ];
} else if ($current === 2) {
    $items = [
        $db[4],
        $db[5],
        $db[6],
        $db[7],
    ];
} else if ($current === 3) {
    $items = [
        $db[7],
        $db[8],
        $db[9],
    ];
} else {
    $current = 1;
    $items = [
        $db[1],
        $db[2],
        $db[3],
        $db[4],
    ];

}

$pagination = new SimplePagination($current, $count);
$pagination->checkLastPage($items);