3v4l.org

run code in 300+ PHP versions simultaneously
<?php $period = new DatePeriod(new DateTime('2010-05-01'), new DateInterval('P1D'), new DateTime('2010-05-10')); $iteratorOutput = $arrayOutput = ''; foreach ($period as $date) { $iteratorOutput .= $date->format('l Y-m-d H:i:s\n'); } foreach (iterator_to_array($period) as $date) { $arrayOutput .= $date->format('l Y-m-d H:i:s\n'); } var_dump($iteratorOutput, $arrayOutput);

preferences:
67.26 ms | 402 KiB | 5 Q