3v4l.org

run code in 300+ PHP versions simultaneously
<?php const INT_COUNT = 10000; // Fill an array with random ints $ints = []; for ($i = 0; $i < INT_COUNT; $i++){ $ints[] = rand(0, 255); } // Sort the ints sort($ints); $start = microtime(true); // Do nothing but access each int in the array for ($i = 0; $i < INT_COUNT; $i++){ $ints[$i]; } $finish = microtime(true); printf("Time taken with sort(): %.3f seconds\n", $finish - $start); // Now do it again, but this time use an asort // Fill an array with random ints $ints = []; for ($i = 0; $i < INT_COUNT; $i++){ $ints[] = rand(0, 255); } // asort the ints asort($ints); $start = microtime(true); // Do nothing but access each int in the array for ($i = 0; $i < INT_COUNT; $i++){ $ints[$i]; } $finish = microtime(true); printf("Time taken with asort(): %.3f seconds\n", $finish - $start);
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.5, 7.1.7, 7.2.0
Time taken with sort(): 0.000 seconds Time taken with asort(): 0.000 seconds
Output for 7.1.6
Time taken with sort(): 0.000 seconds Time taken with asort(): 0.001 seconds
Output for 5.4.0 - 5.4.7, 5.4.9, 5.4.14 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28
Time taken with sort(): 0.001 seconds Time taken with asort(): 0.001 seconds
Output for 5.4.8, 5.4.10 - 5.4.13
Time taken with sort(): 0.001 seconds Time taken with asort(): 0.000 seconds
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/1q1V1 on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_CONST in /in/1q1V1 on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_CONST in /in/1q1V1 on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/1q1V1 on line 2
Process exited with code 255.

preferences:
142.31 ms | 401 KiB | 211 Q