PHP code example of tasofen / pagination

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

    

tasofen / pagination example snippets


$pagination->getHtml($currentPate, $totalPage);
$pagination->getJSON($currentPate, $totalPage);
$pagination->getArray($currentPate, $totalPage);


$pagination = new Tasofen\Pagination([
    'showPages' => 5
]);
echo $pagination->getHtml(7, 20); //currentPage, totalPage

$pagination = new Tasofen\Pagination([
    'showPages' => 5
]);
for($i=1;$i<=10; $i++) {
    echo '<div>';
    echo $pagination->getHtml($i, 10);
    echo '</div>';
}

$pagination = new Tasofen\Pagination([
    'showPages' => 3
]);
$list = $pagination->getArray(7, 20); //currentPage, totalPage
print_r($list);
txt
Array
(
    [0] => Array
        (
            [url] => ?page=1
            [text] => &lt;&lt;
            [active] => false
        )

    [1] => Array
        (
            [url] => ?page=6
            [text] => &lt;
            [active] => false
        )

    [2] => Array
        (
            [url] => ?page=6
            [text] => 6
            [active] => false
        )

    [3] => Array
        (
            [url] => ?page=7
            [text] => 7
            [active] => true
        )

    [4] => Array
        (
            [url] => ?page=8
            [text] => 8
            [active] => false
        )

    [5] => Array
        (
            [url] => ?page=8
            [text] => &gt;
            [active] => false
        )

    [6] => Array
        (
            [url] => ?page=20
            [text] => &gt;&gt;
            [active] => false
        )
)