PHP Paging code

407
.
Example:
A
B
C
D
E
F
G
H
I
J


there have 10 letter, i want to make a paging on per page show 5 letter.

Please someone help me.
.
I'm the Cult of Personality...
$offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0
$on_page = 5;
$array = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J');
$count = count($array);
$array = array_slice($array, $offset, $on_page); 

foreach($array as $value)
echo '<b>'.$value.'</b> ';

echo '<p>PAGES: ';
$col_page = round($count/$on_page);
for($page = 0; $p < $col_page; ++$p)
echo '<a href="?offset='.($p*$on_page).'">'.$p.'</a>';
echo '</p>';

Вибачай брат якщо не те. Як зрозумів так і написав.
.
BoGdAn
I'm the Cult of Personality...
<?php
$offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0;
$on_page = 5;
$array = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J');
$count = count($array);
$array = array_slice($array, $offset, $on_page); 
foreach($array as $value)
echo $value;

echo '<p>PAGES: ';
$col_page = round($count/$on_page);
for($p = -1; $p < $col_page; ++$p)
echo '<a href="?offset='.($p*$on_page).'">'.($p+1).'</a>';
echo '</p>';
Вибачаюсь (треба перевіряти те що пишу Гг)
.
Bro which code was right, say in english plz.
.
Just run $ composer require kilte/pagination
And use it.
.
i want to make paging on it plz help me.
for($i=0;$i<count($cat[1]);$i++)
{
echo '<div class="cat">'.$cat[1][$i].'</div>';
}
.
$list = ['item1', 'item2', 'item3', /* more items... */];

$total = count($list);
$currentPage = isset($_GET['page']) ? intval($_GET['page']) : 1;
$itemsPerPage = 5;
$neighbours = 4;

$pagination = new \Kilte\Pagination\Pagination($total, $currentPage, $itemsPerPage, $neighbours);
$offset = $pagination->offset();
$limit = $pagination->limit();
$listing = array_slice($list, $offset, $limit);

foreach ($listing as $item) {
    var_dump($item);
}

$pages = $pagination->build();
foreach ($pages as $num => $text) {
    echo sprintf('<a href="?page=%s">%s</a><br />', $num, $text);
}
Всего: 7