3v4l.org

run code in 300+ PHP versions simultaneously
<?php $period = new DatePeriod( new DateTime(date('Y-m-d', time())), new DateInterval('P1D'), new DateTime(date('Y-m-d', strtotime('+3 DAYS'))) ); foreach(array('foo', 'bar') as $a) { var_dump($a); foreach ($period as $date) { var_dump(date('d-m-Y', $date->getTimestamp())); } } ?>
Output for 5.3.4 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0
string(3) "foo" string(10) "04-04-2014" string(10) "05-04-2014" string(10) "06-04-2014" string(3) "bar" string(10) "04-04-2014" string(10) "05-04-2014" string(10) "06-04-2014"
Output for 5.3.0 - 5.3.3
string(3) "foo" string(10) "04-04-2014" string(10) "06-04-2014" string(10) "07-04-2014" string(3) "bar"
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Fatal error: Class 'DatePeriod' not found in /in/aBcEG on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: dateperiod in /in/aBcEG on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: dateperiod in /in/aBcEG on line 3

preferences:
179.54 ms | 401 KiB | 217 Q