What are some common approaches to implementing a paginator or pagination feature in PHP for navigating through multiple pages of user lists?

When displaying a large list of users on a website, it's important to implement a paginator or pagination feature to allow users to navigate through multiple pages of the list. This helps improve user experience and page load times by only displaying a subset of users at a time.

// Assuming $users is an array of user data and $perPage is the number of users to display per page
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$totalUsers = count($users);
$totalPages = ceil($totalUsers / $perPage);

$start = ($page - 1) * $perPage;
$end = $start + $perPage;
$paginatedUsers = array_slice($users, $start, $perPage);

foreach ($paginatedUsers as $user) {
    // Display user information
}

// Display pagination links
for ($i = 1; $i <= $totalPages; $i++) {
    echo "<a href='?page=$i'>$i</a> ";
}