What is a common use case for implementing a pagination or "blätter" function in PHP applications?

Implementing a pagination or "blätter" function in PHP applications is commonly used when displaying a large set of data, such as search results or product listings, to improve user experience by breaking up the data into smaller, more manageable chunks. This allows users to navigate through the data more easily and improves performance by reducing the amount of data loaded at once.

// Pagination function
function paginate($total_pages, $current_page, $url) {
    $output = '';

    for ($i = 1; $i <= $total_pages; $i++) {
        if ($i == $current_page) {
            $output .= "<span>$i</span>";
        } else {
            $output .= "<a href='$url&page=$i'>$i</a>";
        }
    }

    return $output;
}

// Example usage
$total_pages = 10;
$current_page = 3;
$url = 'example.php';

echo paginate($total_pages, $current_page, $url);