How can PHP be utilized to create a navigation box with multiple subpoints on a website?
To create a navigation box with multiple subpoints on a website using PHP, you can use nested arrays to represent the main navigation items and their corresponding subpoints. Then, you can iterate over these arrays to dynamically generate the navigation structure on the webpage.
<?php
$navigation = array(
"Home" => array(),
"About" => array("History", "Team", "Mission"),
"Services" => array("Web Design", "Graphic Design", "SEO"),
"Contact" => array("Location", "Email", "Phone")
);
echo '<ul>';
foreach ($navigation as $mainItem => $subpoints) {
echo '<li>' . $mainItem;
if (!empty($subpoints)) {
echo '<ul>';
foreach ($subpoints as $subpoint) {
echo '<li>' . $subpoint . '</li>';
}
echo '</ul>';
}
echo '</li>';
}
echo '</ul>';
?>