codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php $total = 1024; $per_page = 10; $current_page = 42; $adjacent_links = 4; function Pagination($data, $limit = null, $current = null, $adjacents = null) { $result = array(); if (isset($data, $limit) === true) { $result = range(1, ceil($data / $limit)); if (isset($current, $adjacents) === true) { if (($adjacents = floor($adjacents / 2) * 2 + 1) >= 1) { $result = array_slice($result, max(0, min(count($result) - $adjacents, intval($current) - ceil($adjacents / 2))), $adjacents); } } } return $result; } print_r(Pagination($total, $per_page, $current_page, $adjacent_links)); ?>
Private
[
?
]
Run code