3v4l.org

run code in 300+ PHP versions simultaneously
<?php $period = [ 'startDate' => new DateTime('2014/11/19'), 'endDate' => new DateTime('2015/2/01') ]; $fullTimeSpan = ($period['endDate']->getTimestamp()-$period['startDate']->getTimestamp())/(24*3600); $timeSpans = []; //hostelbookers can't handle updating more than 65 days in a row if ($fullTimeSpan <= $this->allowedTimeSpan) { $timeSpans[] = [ 'day' => $period['startDate']->format('d'), 'month' => $period['startDate']->format('n'), 'year' => $period['startDate']->format('Y'), 'timeSpan' => $fullTimeSpan ] } else { $startDate = new \DateTime(sprintf( '%s/%s/%s', $period['startDate']->format('Y'), $period['startDate']->format('n'), $period['startDate']->format('d'), )); $interval = new DateInterval(sprintf( 'P%dD', $this->allowedTimeSpan )); while ($fullTimeSpan > 0) { $timeSpans[] = [ 'day' => $startDate->format('d'), 'month' => $startDate->format('n'), 'year' => $startDate->format('Y'), 'timeSpan' => $fullTimeSpan <= $this->allowedTimeSpan ? $fullTimeSpan : $this->allowedTimeSpan ]; $fullTimeSpan -= $this->allowedTimeSpan; $startDate->add($interval); } } var_dump($timeSpans);
Output for 5.4.0 - 5.4.35
Parse error: syntax error, unexpected '}' in /in/2bBkV on line 18
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/2bBkV on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/2bBkV on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/2bBkV on line 2
Process exited with code 255.

preferences:
214.94 ms | 1395 KiB | 125 Q