3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test_iterator($dirname) { $files = array(); $dir = new DirectoryIterator($dirname); while($dir->valid()) { $files[] = (string)$dir->current(); $dir->next(); } return $files; } function test_iterator_bug($dirname) { $files = array(); $dir = new DirectoryIterator($dirname); foreach($dir as $file) { $files[] = (string)$file; } return $files; } echo 'PHP version: ' . phpversion() . "\n\n"; $dirname = dirname(__FILE__); foreach (array('iterator', 'iterator_bug') as $test_name) { echo "--- {$test_name} ---\n"; $foo = "test_{$test_name}"; var_dump($foo($dirname)); echo "\n"; }

preferences:
31.53 ms | 402 KiB | 5 Q