Can you explain the process of linking navigation structures and text content in PHP for a website?

To link navigation structures and text content in PHP for a website, you can create an associative array that maps navigation items to their respective content pages. Then, you can use this array to dynamically generate navigation links on your website. When a navigation link is clicked, you can use PHP to retrieve the corresponding content page and display it on the website.

<?php
// Define an associative array mapping navigation items to content pages
$navigation = array(
    "Home" => "home.php",
    "About" => "about.php",
    "Services" => "services.php",
    "Contact" => "contact.php"
);

// Loop through the navigation array to generate navigation links
foreach ($navigation as $item => $page) {
    echo "<a href='$page'>$item</a>";
}

// Retrieve the content page based on the URL parameter
if (isset($_GET['page']) && array_key_exists($_GET['page'], $navigation)) {
    include $navigation[$_GET['page']];
} else {
    include "home.php"; // Default to home page
}
?>