How can multiple date ranges be displayed simultaneously in a PHP script?

When displaying multiple date ranges simultaneously in a PHP script, one approach is to use a loop to iterate through each date range and format it accordingly before outputting it to the page. This way, you can easily manage and display multiple date ranges without hardcoding each one individually.

<?php
// Define an array of date ranges
$dateRanges = [
    ['start' => '2022-01-01', 'end' => '2022-01-10'],
    ['start' => '2022-02-01', 'end' => '2022-02-15'],
    ['start' => '2022-03-01', 'end' => '2022-03-20']
];

// Loop through each date range and display it
foreach ($dateRanges as $dateRange) {
    echo "Start Date: " . $dateRange['start'] . " - End Date: " . $dateRange['end'] . "<br>";
}
?>