What are some best practices for handling and displaying TV schedule data in PHP scripts?

When handling and displaying TV schedule data in PHP scripts, it is important to properly format and organize the data to ensure it is easily readable and user-friendly. One best practice is to use arrays to store the schedule data, making it easier to iterate through and display the information in a structured manner.

// Sample TV schedule data
$tvSchedule = [
    'Monday' => [
        '8:00 AM' => 'Morning Show',
        '12:00 PM' => 'News Hour',
        '7:00 PM' => 'Prime Time Movie'
    ],
    'Tuesday' => [
        '9:00 AM' => 'Cartoon Marathon',
        '1:00 PM' => 'Cooking Show',
        '8:00 PM' => 'Reality TV'
    ],
    // Add more days and schedule data as needed
];

// Display TV schedule data
foreach ($tvSchedule as $day => $schedule) {
    echo "<h2>$day</h2>";
    
    echo "<ul>";
    foreach ($schedule as $time => $show) {
        echo "<li>$time - $show</li>";
    }
    echo "</ul>";
}