Calculate pagination variables for database queries or array slicing.
Source Code
$totalItems = 100; // Total items
$itemsPerPage = 10; // Items per page
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1; // Current page
$totalPages = ceil($totalItems / $itemsPerPage); // Total pages
$start = ($page - 1) * $itemsPerPage; // Starting item index for the current page
echo "Showing page $page of $totalPages";