How can PHP be utilized to create multiple pages for news archives on a website?

To create multiple pages for news archives on a website using PHP, you can implement pagination. This involves displaying a certain number of news articles per page and providing navigation links to move between pages of news archives.

<?php
// Assuming $newsArticles is an array containing all the news articles

$articlesPerPage = 10;
$totalArticles = count($newsArticles);
$totalPages = ceil($totalArticles / $articlesPerPage);

$page = isset($_GET['page']) ? $_GET['page'] : 1;
$start = ($page - 1) * $articlesPerPage;
$end = $start + $articlesPerPage;

for ($i = $start; $i < $end && $i < $totalArticles; $i++) {
    echo $newsArticles[$i]['title'] . "<br>";
    echo $newsArticles[$i]['content'] . "<br><br>";
}

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