3v4l.org

run code in 300+ PHP versions simultaneously
<?php function returnTime(callable $function, int $repeat = 200) { $tests = []; for ($i = 0; $i < $repeat; ++$i) { $startTime = microtime(true); $function(); $endTime = microtime(true); $tests[] = $endTime - $startTime; } // Representing the average return array_sum($tests) / $repeat; } $array = array_fill(0, 400000, 1); echo "Duration of array_slice() + key(): ", returnTime(function() use ($array) { $lastKey = key(array_slice($array, -1, 1, true)); }); echo PHP_EOL; echo "Duration of end() + key(): " , returnTime(function() use ($array){ end($array); $lastKey = key($array); }); echo PHP_EOL; echo "Duration of array_key_last(): " , returnTime(function() use ($array){ $lastKey = array_key_last($array); });

Abusive script

This script was stopped while abusing our resources

Output for 7.3.7
Duration of array_slice() + key(): 0.00062096834182739 Duration of end() + key(): 0.010920312404633 Duration of array_key_last(): 1.1205673217773E-7
Output for 7.3.6
Duration of array_slice() + key(): 0.00057072639465332 Duration of end() + key(): 0.0097994363307953 Duration of array_key_last(): 1.1920928955078E-7
Output for 7.3.5
Duration of array_slice() + key(): 0.00056238055229187 Duration of end() + key(): 0.010025978088379 Duration of array_key_last(): 1.0251998901367E-7
Output for 7.3.4
Duration of array_slice() + key(): 0.00091255784034729 Duration of end() + key(): 0.010423823595047 Duration of array_key_last(): 1.072883605957E-7
Output for 7.3.3
Duration of array_slice() + key(): 0.00082037448883057 Duration of end() + key(): 0.010158874988556 Duration of array_key_last(): 1.0967254638672E-7
Output for 7.3.2
Duration of array_slice() + key(): 0.00072634339332581 Duration of end() + key(): 0.0060430252552032 Duration of array_key_last(): 1.1444091796875E-7
Output for 7.3.1
Duration of array_slice() + key(): 0.00053919792175293 Duration of end() + key(): 0.0058684813976288 Duration of array_key_last(): 1.0967254638672E-7
Output for 7.3.0
Duration of array_slice() + key(): 0.00053236603736877 Duration of end() + key(): 0.0056568360328674 Duration of array_key_last(): 9.5367431640625E-8
Output for 7.2.20
Duration of array_slice() + key(): 0.0011549818515778 Duration of end() + key():
Process exited with code 137.
Output for 7.2.19
Duration of array_slice() + key(): 0.00066628575325012 Duration of end() + key(): 0.0099083518981934 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.18
Duration of array_slice() + key(): 0.00067405104637146 Duration of end() + key(): 0.0095488381385803 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.17
Duration of array_slice() + key(): 0.00060203671455383 Duration of end() + key(): 0.010150420665741 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.16
Duration of array_slice() + key(): 0.0006359601020813 Duration of end() + key(): 0.010157651901245 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.15
Duration of array_slice() + key(): 0.00052675127983093 Duration of end() + key(): 0.0058656847476959 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.14
Duration of array_slice() + key(): 0.00051964521408081 Duration of end() + key(): 0.005734281539917 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.13
Duration of array_slice() + key(): 0.00054192304611206 Duration of end() + key(): 0.0060082852840424 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.12
Duration of array_slice() + key(): 0.00078027367591858 Duration of end() + key(): 0.0060601329803467 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.11
Duration of array_slice() + key(): 0.0012964498996735 Duration of end() + key(): 0.0068058490753174 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.10
Duration of array_slice() + key(): 0.00093976974487305 Duration of end() + key(): 0.0065152943134308 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.9
Duration of array_slice() + key(): 0.0010134220123291 Duration of end() + key(): 0.0062645041942596 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.8
Duration of array_slice() + key(): 0.00067277073860168 Duration of end() + key(): 0.0066257512569427 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.7
Duration of array_slice() + key(): 0.0010355639457703 Duration of end() + key(): 0.0065439546108246 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.6
Duration of array_slice() + key(): 0.0005583918094635 Duration of end() + key(): 0.0060230052471161 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.5
Duration of array_slice() + key(): 0.00056422591209412 Duration of end() + key(): 0.00593918800354 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.4
Duration of array_slice() + key(): 0.00056680560112 Duration of end() + key(): 0.0058510494232178 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.3
Duration of array_slice() + key(): 0.00055015444755554 Duration of end() + key(): 0.0060550379753113 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.2
Duration of array_slice() + key(): 0.00058505654335022 Duration of end() + key(): 0.0060098385810852 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.1
Duration of array_slice() + key(): 0.00060984253883362 Duration of end() + key(): 0.0055398321151733 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.2.0
Duration of array_slice() + key(): 0.00054110050201416 Duration of end() + key(): 0.005816947221756 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.1.30
Duration of array_slice() + key(): 0.00052793145179749 Duration of end() + key(): 0.0053964221477509 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.1.29
Duration of array_slice() + key(): 0.00051459670066833 Duration of end() + key(): 0.0053593289852142 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.1.28
Duration of array_slice() + key(): 0.00065733790397644 Duration of end() + key(): 0.0058814942836761 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.1.27
Duration of array_slice() + key(): 0.00069940686225891 Duration of end() + key(): 0.0058408355712891 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.1.26
Duration of array_slice() + key(): 0.00060970902442932 Duration of end() + key(): 0.0059105515480042 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.
Output for 7.1.25
Duration of array_slice() + key(): 0.00062633275985718 Duration of end() + key(): 0.0058737146854401 Duration of array_key_last(): Fatal error: Uncaught Error: Call to undefined function array_key_last() in /in/MFe3g:34 Stack trace: #0 /in/MFe3g(10): {closure}() #1 /in/MFe3g(35): returnTime(Object(Closure)) #2 {main} thrown in /in/MFe3g on line 34
Process exited with code 255.

preferences:
67.72 ms | 462 KiB | 5 Q