How can external links be integrated into a PHP array for navigation menus?

When integrating external links into a PHP array for navigation menus, you can simply add the external links as values in the array along with the corresponding menu item labels. This allows you to dynamically generate navigation menus with both internal and external links. You can then loop through the array to output the menu items as HTML links.

$menuItems = [
    'Home' => 'index.php',
    'About' => 'about.php',
    'External Link' => 'https://www.example.com',
    'Contact' => 'contact.php',
];

echo '<ul>';
foreach ($menuItems as $label => $link) {
    echo '<li><a href="' . $link . '">' . $label . '</a></li>';
}
echo '</ul>';