3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = ['Red orange 2016','orange 2017' ,'Mango 2018' ,'Granny Smith apple 2018' ,'apple 2015']; $a = array(); // create two new arrays to hold fruit and year $b = array(); $temp = array(); foreach($test as $item){ $temp = explode(" ", $item); // explode the fruit/year to temp array $a[] = implode(" ", array_splice($temp, 0, -1)); // implode all but the last item as "fruit" $b[] = end($temp); // last item is the year } array_multisort($b, $a); // sort the new arrays $result=array(); for($i=count($b)-1; $i>=0; $i--){ // looping backwards to only count() once. (faster) $result[] = $a[$i] . " " . $b[$i]; // rebuild the new array with correct sorting. } var_dump($result);

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.3.130.0030.00516.77
8.3.120.0030.00619.17
8.3.110.0090.00020.94
8.3.100.0040.01424.06
8.3.90.0040.01126.77
8.3.80.0090.00017.97
8.3.70.0070.00716.63
8.3.60.0090.01218.31
8.3.50.0080.00717.32
8.3.40.0120.00318.53
8.3.30.0140.00018.70
8.3.20.0040.00420.18
8.3.10.0030.00521.90
8.3.00.0000.00820.80
8.2.250.0040.00418.48
8.2.240.0130.00017.00
8.2.230.0060.00322.58
8.2.220.0130.00737.54
8.2.210.0030.00526.77
8.2.200.0030.00618.41
8.2.190.0060.00916.58
8.2.180.0130.01018.16
8.2.170.0120.00322.96
8.2.160.0070.00719.33
8.2.150.0040.00424.18
8.2.140.0000.00724.66
8.2.130.0040.00419.39
8.2.120.0000.00726.35
8.2.110.0000.00922.26
8.2.100.0040.00917.66
8.2.90.0040.00418.03
8.2.80.0040.00419.39
8.2.70.0000.00817.75
8.2.60.0030.00517.93
8.2.50.0030.00518.34
8.2.40.0000.00820.37
8.2.30.0040.00419.31
8.2.20.0030.00518.22
8.2.10.0040.00418.20
8.2.00.0040.00417.99
8.1.300.0030.00518.09
8.1.290.0090.00030.84
8.1.280.0110.00725.92
8.1.270.0000.00823.79
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00422.14
8.1.230.0040.00720.97
8.1.220.0030.00617.74
8.1.210.0030.00518.98
8.1.200.0030.00617.35
8.1.190.0040.00417.10
8.1.180.0050.00218.10
8.1.170.0030.00518.65
8.1.160.0040.00418.88
8.1.150.0040.00422.01
8.1.140.0070.00019.58
8.1.130.0000.00718.88
8.1.120.0040.00417.44
8.1.110.0040.00417.35
8.1.100.0050.00317.46
8.1.90.0030.00617.36
8.1.80.0040.00417.41
8.1.70.0000.00717.38
8.1.60.0040.00417.50
8.1.50.0040.00417.50
8.1.40.0030.00617.49
8.1.30.0030.00517.60
8.1.20.0000.00817.50
8.1.10.0000.00817.55
8.1.00.0030.00617.46
8.0.300.0000.00820.03
8.0.290.0020.00516.75
8.0.280.0000.00818.50
8.0.270.0000.00817.13
8.0.260.0030.00318.80
8.0.250.0030.00517.00
8.0.240.0070.00016.93
8.0.230.0000.00716.94
8.0.220.0030.00616.90
8.0.210.0030.00316.90
8.0.200.0000.00616.96
8.0.190.0000.00716.84
8.0.180.0050.00316.95
8.0.170.0000.00716.88
8.0.160.0000.00716.77
8.0.150.0070.00016.79
8.0.140.0030.00416.68
8.0.130.0050.00313.30
8.0.120.0000.00716.86
8.0.110.0000.00816.95
8.0.100.0040.00417.00
8.0.90.0040.00416.69
8.0.80.0090.00616.86
8.0.70.0040.00416.92
8.0.60.0000.00716.98
8.0.50.0050.00216.87
8.0.30.0130.00516.99
8.0.20.0080.01017.40
8.0.10.0000.00716.83
8.0.00.0110.00716.82
7.4.330.0050.00015.55
7.4.320.0030.00316.50
7.4.300.0000.00616.50
7.4.290.0080.00016.57
7.4.280.0000.00816.56
7.4.270.0030.00316.58
7.4.260.0000.00916.49
7.4.250.0040.00416.58
7.4.240.0070.00016.41
7.4.230.0030.00316.63
7.4.220.0070.01116.70
7.4.210.0100.01016.52
7.4.200.0000.00716.44
7.4.160.0110.00516.45
7.4.150.0080.00917.40
7.4.140.0120.00817.86
7.4.130.0090.00916.41
7.4.120.0110.00816.51
7.4.110.0110.00616.48
7.4.100.0040.01416.61
7.4.90.0030.01316.40
7.4.80.0160.00719.39
7.4.70.0040.01316.60
7.4.60.0060.00916.49
7.4.50.0030.01316.44
7.4.40.0060.01516.73
7.4.30.0160.00316.45
7.4.00.0040.01214.68
7.3.330.0030.00313.00
7.3.320.0050.00013.24
7.3.310.0070.00016.25
7.3.300.0070.00016.28
7.3.290.0080.00816.28
7.3.280.0080.00916.27
7.3.270.0110.00617.40
7.3.260.0090.01116.38
7.3.250.0140.00816.41
7.3.240.0110.00616.36
7.3.230.0080.00816.44
7.3.210.0140.00316.23
7.3.200.0070.01016.28
7.3.190.0150.00316.32
7.3.180.0000.01716.49
7.3.170.0110.00616.26
7.3.160.0030.01716.72
7.2.330.0070.01016.71
7.2.320.0070.01216.68
7.2.310.0040.01616.80
7.2.300.0150.00716.58
7.2.290.0060.00916.80
7.2.60.0070.00716.99
7.1.200.0060.00615.66
7.1.80.5830.00916.14
7.1.70.5540.01215.35
7.1.60.5700.02133.23
7.1.50.5500.01033.07
7.1.40.0340.01332.67
7.1.30.0310.01332.70
7.1.20.0270.01032.49
7.1.10.0080.01214.69
7.1.00.0110.00814.95
7.0.200.5910.01015.01
7.0.190.5210.01614.99
7.0.180.0090.01614.52
7.0.170.0190.00814.68
7.0.160.0120.00814.52
7.0.150.0100.01014.37
7.0.140.0050.01414.80
7.0.130.0070.01414.52
7.0.120.0150.00714.60
7.0.110.0100.01314.46
7.0.100.0130.00914.45
7.0.90.0030.01814.44
7.0.80.0300.00014.59
7.0.70.5940.00314.42
7.0.60.0060.01214.04
7.0.50.0130.00814.48
7.0.40.0060.01214.63
7.0.30.0160.00414.62
7.0.20.0080.01314.69
7.0.10.0030.01414.40
7.0.00.0070.00714.65

preferences:
26.63 ms | 403 KiB | 5 Q