How can PHP be utilized to generate tables for displaying employee schedules in a shift plan?

To generate tables for displaying employee schedules in a shift plan using PHP, you can create an array containing the employee names and their corresponding shift schedules. Then, loop through the array to generate the table rows dynamically, displaying the employee names and their shift schedules in each cell.

<?php
// Sample array containing employee names and shift schedules
$employeeSchedules = array(
    "Alice" => "Day Shift",
    "Bob" => "Night Shift",
    "Charlie" => "Morning Shift",
    "David" => "Afternoon Shift"
);

// Generate the table structure
echo "<table border='1'>";
echo "<tr><th>Employee</th><th>Shift Schedule</th></tr>";

// Loop through the array to populate the table rows
foreach ($employeeSchedules as $employee => $schedule) {
    echo "<tr><td>$employee</td><td>$schedule</td></tr>";
}

echo "</table>";
?>