How can include files be properly integrated into a dynamic PHP menu?

When creating a dynamic PHP menu, it is important to properly integrate include files to ensure easy maintenance and scalability. One way to do this is by creating separate PHP files for the menu items and then including them in the main menu file. This allows for easy updates and modifications to the menu items without having to edit the main file each time.

<?php
// main_menu.php

// Include file for menu items
include 'menu_items.php';

// Loop through menu items and display them
echo '<ul>';
foreach ($menu_items as $item) {
    echo '<li><a href="' . $item['url'] . '">' . $item['title'] . '</a></li>';
}
echo '</ul>';
?>