How can PHP be utilized to dynamically format and display specific days of the week, such as highlighting the current day in red?

To dynamically format and display specific days of the week, such as highlighting the current day in red, you can use PHP to get the current day of the week and apply a CSS class to style it accordingly. By comparing the current day with each day of the week, you can dynamically apply the styling to the current day.

<?php
$currentDay = date("l");
$days = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

foreach($days as $day){
    if($day == $currentDay){
        echo "<span style='color: red;'>$day</span><br>";
    } else {
        echo "$day<br>";
    }
}
?>