DatePeriod iterates a date range without a loop counter

Walking every day between two dates is usually a while loop with a manual increment and an off-by-one at one end. DatePeriod is an iterator over a start, an interval and an end, so the loop body is the only thing left to get wrong.

$period = new DatePeriod(
    new DateTimeImmutable('2015-06-01'),
    new DateInterval('P1D'),
    new DateTimeImmutable('2015-07-01')
);

foreach ($period as $day) {
    $report[$day->format('Y-m-d')] = 0;
}

The end date is exclusive, which is the one thing worth remembering — the loop above produces June only. Passing an integer instead of an end date gives that many recurrences after the start, so the count is one higher than most people expect. It also handles month lengths and DST transitions correctly, which hand-rolled day arithmetic frequently does not.