Files
CIEF Dev Team 09421c18b8 Initial commit
2018-03-07 16:15:53 +08:00

17 lines
471 B
PHP

<?php
function paging($input, $page, $show_per_page) {
$start = $page;
$end = $start + $show_per_page;
$count = count($input);
// Conditionally return results
if ($start < 0 || $count <= $start)
// Page is out of range
return array();
else if ($count <= $end)
// Partially-filled page
return array_slice($input, $start);
else
// Full page
return array_slice($input, $start, $end - $start);
}