How can PHP arrays be effectively utilized to simplify menu and title management in a website?

Managing menus and titles in a website can be simplified by using PHP arrays to store the menu items and page titles. By organizing this information in arrays, it becomes easier to dynamically generate menus and set titles based on the current page being viewed. This approach reduces code duplication and makes it easier to update menu items and titles across the website.

$menuItems = [
    'Home' => 'index.php',
    'About Us' => 'about.php',
    'Services' => 'services.php',
    'Contact Us' => 'contact.php'
];

$pageTitles = [
    'index.php' => 'Home',
    'about.php' => 'About Us',
    'services.php' => 'Services',
    'contact.php' => 'Contact Us'
];

// Usage example: 
$currentPage = 'services.php';
echo $pageTitles[$currentPage]; // Output: Services