3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(0); $results = array(); for($i = 0; $i < 10000; $i++) { $results[] = (object) rand(0, 100000); } $start = microtime(true); for($i = 0; $i < 1000; $i++) { $alreadyOutput = array(); foreach ($results as $result) { if(in_array($result->date, $alreadyOutput)){ continue; } $alreadyOutput[] = $result->date; } } echo "in_array: ".(microtime(true) - $start)."ms || "; $start2 = microtime(true); for($i = 0; $i < 1000; $i++) { $echoedArray = array(); foreach ($results as $result) { if ($echoedArray[$result->date]) { continue; } $echoedArray[$result->date] = true; } } echo "by key: ".(microtime(true) - $start2)."ms";
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.20, 7.1.5, 7.1.7

Process exited with code 137.
Output for 7.1.6
in_array: 2.2881062030792ms ||
Process exited with code 137.
Output for 7.1.0
in_array: 2.1887409687042ms ||
Process exited with code 137.
Output for 7.0.14
in_array: 2.2460691928864ms ||
Process exited with code 137.
Output for 7.0.6
in_array: 2.3990919589996ms ||
Process exited with code 137.
Output for 7.0.5
in_array: 2.2436730861664ms ||
Process exited with code 137.
Output for 7.0.4
in_array: 2.2440919876099ms ||
Process exited with code 137.
Output for 7.0.3
in_array: 2.2589280605316ms ||
Process exited with code 137.
Output for 7.0.2
in_array: 2.2970550060272ms ||
Process exited with code 137.
Output for 7.0.1
in_array: 2.4009039402008ms ||
Process exited with code 137.
Output for 7.0.0
in_array: 2.2958719730377ms ||
Process exited with code 137.

preferences:
80.08 ms | 401 KiB | 91 Q