3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = range(0, 99); $start = microtime(1); $result = []; for ($i = 0; $i < 100; $i++) if (preg_match("#$i#", $array[$i])) $result[] = $array[$i]; print "for \$i took ".($start - microtime(1))." seconds\n"; $start = microtime(1); $result = []; for ($i = 0; $i < 100; $i++) if (preg_match("#\d#", $array[$i])) $result[] = $array[$i]; print "for \\d took ".($start - microtime(1))." seconds\n"; $start = microtime(1); $result = []; foreach ($array as $entry) if (preg_match("#\d#", $entry)) $result[] = $entry; print "foreach \\d took ".($start - microtime(1))." seconds\n"; $start = microtime(1); $result = []; $result = preg_grep("#\d#", $array); print "preg_grep \\d took ".($start - microtime(1))." seconds\n";

preferences:
30.5 ms | 402 KiB | 5 Q