How can PHP be used to mark multiple days in a calendar for specific events or holidays?

To mark multiple days in a calendar for specific events or holidays using PHP, you can create an array that contains the dates to be marked and then loop through the calendar days to check if each day should be marked. If a day matches one of the dates in the array, you can apply a CSS class or any other visual indicator to highlight that day on the calendar.

<?php
// Array of dates to be marked on the calendar
$markedDates = ['2022-01-01', '2022-02-14', '2022-12-25'];

// Loop through calendar days
for ($day = 1; $day <= 31; $day++) {
    $currentDate = date('Y-m-d', strtotime("2022-01-$day"));
    
    if (in_array($currentDate, $markedDates)) {
        echo '<div class="marked-day">' . $day . '</div>';
    } else {
        echo '<div>' . $day . '</div>';
    }
}
?>