What is the purpose of the createPages function in the PHP code provided?

The purpose of the createPages function in the provided PHP code is to generate a specified number of page links based on the total number of items and items per page. This function helps in creating pagination for a list of items displayed on a web page.

function createPages($totalItems, $itemsPerPage) {
    $totalPages = ceil($totalItems / $itemsPerPage);
    $pages = [];

    for ($i = 1; $i <= $totalPages; $i++) {
        $pages[] = $i;
    }

    return $pages;
}

// Example usage
$totalItems = 100;
$itemsPerPage = 10;
$pages = createPages($totalItems, $itemsPerPage);

foreach ($pages as $page) {
    echo "<a href='page.php?page=$page'>$page</a>";
}