3v4l.org

run code in 500+ PHP versions simultaneously
<?php $numbers = range(0,100000); $start = microtime(true); $justThousand = []; foreach($numbers as $num){ if($num > 1000 && $num < 6000){ $justThousand[] = $num; } } $end = microtime(true); echo "foreach: ".$end - $start."\n"; $start = microtime(true); function IsThousand($num){ return $num > 1000 && $num < 6000; } $justThousand = array_filter($numbers,'IsThousand'); $end = microtime(true); echo "array_filter: ".$end - $start;

preferences:
42.79 ms | 745 KiB | 5 Q