<?php

function PAGE($MYSQLVODS,$page,$pagesize){
$pagesize = max(1, (int)$pagesize);
$total = max(1, (int)ceil(count((array)$MYSQLVODS) / $pagesize));
$current = max(1, min((int)$page, $total));

return array(
    'source' => array_slice((array)$MYSQLVODS, ($current - 1) * $pagesize, $pagesize),
    'page' => $current,
    'prev' => max(1, $current - 1),
    'next' => min($total, $current + 1),
    'total' => $total,
);
}
?>
