How can a for-loop be used to increment days in PHP, such as for calculating dates in the future?

To increment days in PHP using a for-loop, you can start with the current date and then use a for-loop to add the desired number of days. This can be useful for calculating future dates or iterating over a range of dates. By incrementing the date within the loop, you can easily calculate the dates in the future.

$startDate = date('Y-m-d');
$numberOfDays = 7;

for ($i = 1; $i <= $numberOfDays; $i++) {
    $futureDate = date('Y-m-d', strtotime($startDate . ' + ' . $i . ' days'));
    echo $futureDate . "\n";
}