3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ( '3' => 10, '2' => 2, '5' => 'Nakiya', ); /** * Sort an array by key. */ function sortbyKeys($array, $direction = 'ASC') { $direction = (strtolower($direction) === 'desc') ? SORT_DESC : SORT_ASC; if ($direction === SORT_ASC) { ksort($array); } else { krsort($array); } return $array; } var_dump(sortbyKeys($array));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.30.0050.00320.39
8.4.20.0180.00318.57
8.4.10.0080.00017.82
8.3.160.0090.00917.32
8.3.150.0110.00717.13
8.3.140.0080.00017.18
8.3.130.0090.00618.37
8.3.120.0030.00618.82
8.3.110.0080.00020.94
8.3.100.0120.00024.06
8.3.90.0030.01626.77
8.3.80.0030.00616.38
8.3.70.0120.00616.58
8.3.60.0180.00318.43
8.3.50.0080.00619.17
8.3.40.0120.00318.73
8.3.30.0070.00718.41
8.3.20.0030.00622.66
8.3.10.0040.00421.95
8.3.00.0040.00420.77
8.2.270.0000.00717.13
8.2.260.0000.00818.13
8.2.250.0080.01216.78
8.2.240.0000.00816.93
8.2.230.0000.00822.58
8.2.220.0000.00937.54
8.2.210.0120.00626.77
8.2.200.0110.00018.04
8.2.190.0140.00716.63
8.2.180.0140.00725.92
8.2.170.0180.00318.96
8.2.160.0160.00322.96
8.2.150.0040.00425.66
8.2.140.0070.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00026.16
8.2.110.0100.01322.11
8.2.100.0000.01217.81
8.2.90.0060.00320.42
8.2.80.0050.00317.97
8.2.70.0000.00817.93
8.2.60.0040.00417.91
8.2.50.0030.00618.10
8.2.40.0080.00019.24
8.2.30.0040.00419.17
8.2.20.0060.00317.90
8.2.10.0040.00419.30
8.2.00.0060.00319.27
8.1.310.0100.00718.56
8.1.300.0040.00417.88
8.1.290.0030.00630.84
8.1.280.0120.00625.92
8.1.270.0050.00323.96
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0030.00622.42
8.1.230.0110.00020.85
8.1.220.0000.00817.79
8.1.210.0050.00318.92
8.1.200.0030.00617.22
8.1.190.0060.00317.10
8.1.180.0040.00718.10
8.1.170.0040.00420.91
8.1.160.0070.00019.00
8.1.150.0070.00018.93
8.1.140.0040.00420.18
8.1.130.0000.00720.07
8.1.120.0070.00017.29
8.1.110.0050.00217.27
8.1.100.0040.00417.42
8.1.90.0070.00017.39
8.1.80.0040.00717.38
8.1.70.0000.00717.37
8.1.60.0060.00317.50
8.1.50.0000.00817.56
8.1.40.0030.00517.40
8.1.30.0030.00517.69
8.1.20.0050.00317.64
8.1.10.0000.00817.55
8.1.00.0040.00417.41
8.0.300.0040.00419.91
8.0.290.0050.00216.63
8.0.280.0000.00718.38
8.0.270.0000.00717.20
8.0.260.0000.00620.07
8.0.250.0070.00016.87
8.0.240.0070.00616.75
8.0.230.0000.00716.85
8.0.220.0070.00016.83
8.0.210.0030.00516.74
8.0.200.0030.00316.88
8.0.190.0050.00316.89
8.0.180.0050.00316.88
8.0.170.0050.00316.90
8.0.160.0050.00216.78
8.0.150.0000.00716.77
8.0.140.0000.00716.74
8.0.130.0000.00613.18
8.0.120.0000.00716.65
8.0.110.0000.00716.84
8.0.100.0000.00716.89
8.0.90.0060.00316.89
8.0.80.0090.01016.86
8.0.70.0040.00416.86
8.0.60.0000.00716.84
8.0.50.0050.00316.80
8.0.30.0030.01417.29
8.0.20.0140.00917.04
8.0.10.0040.00417.00
8.0.00.0190.00016.75
7.4.330.0020.00215.55
7.4.320.0030.00316.43
7.4.300.0000.00616.50
7.4.290.0000.00916.57
7.4.280.0000.00816.53
7.4.270.0000.00716.58
7.4.260.0030.00313.29
7.4.250.0000.00816.41
7.4.240.0030.00516.57
7.4.230.0040.00416.30
7.4.220.0030.00316.51
7.4.210.0080.00816.59
7.4.200.0070.00016.48
7.4.130.0060.01216.47
7.4.120.0200.00416.57
7.4.110.0090.00916.52
7.4.100.0100.01316.45
7.4.90.0150.01216.53
7.4.80.0080.00919.39
7.4.70.0070.01016.55
7.4.60.0030.01316.41
7.4.50.0090.00616.59
7.4.40.0090.01516.37
7.4.00.0110.00415.00
7.3.330.0040.00416.34
7.3.320.0060.00013.37
7.3.310.0030.00316.30
7.3.300.0030.00316.32
7.3.290.0040.01116.23
7.3.280.0070.00716.29
7.3.260.0080.01016.45
7.3.240.0110.00816.56
7.3.230.0100.00716.70
7.3.210.0200.00316.34
7.3.200.0060.01016.24
7.3.190.0130.00316.52
7.3.180.0090.00916.29
7.3.170.0120.00416.37
7.3.160.0060.01216.31
7.3.120.0070.00714.75
7.3.110.0030.01015.03
7.3.100.0060.00814.75
7.3.90.0050.00714.86
7.3.80.0090.00914.81
7.3.70.0080.00514.71
7.3.60.0030.01314.61
7.3.50.0090.00914.80
7.3.40.0080.00714.79
7.3.30.0060.01114.68
7.3.20.0060.01115.58
7.3.10.0100.00615.74
7.3.00.0070.00915.56
7.2.330.0070.01016.39
7.2.320.0090.00916.61
7.2.310.0170.00716.25
7.2.300.0100.01316.50
7.2.290.0040.01216.48
7.2.240.0030.01014.86
7.2.230.0100.00115.12
7.2.220.0050.00814.95
7.2.210.0060.00814.80
7.2.200.0120.00414.76
7.2.190.0030.01214.94
7.2.180.0100.00814.83
7.2.170.0110.00514.92
7.2.160.0060.01114.95
7.2.150.0060.01115.88
7.2.140.0100.00415.97
7.2.130.0070.00915.97
7.2.120.0030.01215.78
7.2.110.0050.01115.89
7.2.100.0100.00615.74
7.2.90.0120.00316.01
7.2.80.0090.00615.91
7.2.70.0060.01115.86
7.2.60.0070.00715.81
7.2.50.0080.00715.78
7.2.40.0090.00515.97
7.2.30.0070.00715.78
7.2.20.0110.00515.81
7.2.10.0020.01215.93
7.2.00.0100.00415.85
7.1.330.0060.00915.85
7.1.320.0070.00914.90
7.1.310.0100.00514.92
7.1.300.0060.00914.90
7.1.290.0080.00914.63
7.1.280.0080.00614.68
7.1.270.0120.00014.80
7.1.260.0050.00914.90
7.1.250.0070.00914.91

preferences:
31.37 ms | 403 KiB | 5 Q