3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Kvatera', 0, 8.4, 11762], ['Loft', 0, 8.9, 12154], ['Apartment', 0, 8.5, 12467], ['Hos', 0, 8.0, 13252], ['Apart Cent', 0, 9.0, 13778], ['Enbeve', 0, 8.4, 13778], ['Loft sen', 0, 8.8, 13806], ['Dream', 0, 9.1, 14114], ]; $totalHotelsNumber = 2; $starCoef = 0.2; $ratingCoef = 2000; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } for ( $i=0; $i<count($hotels); $i++ ) { for ( $j=$i+1; $j<count($hotels); $j++ ) { echo 'Comparing '.$hotels[$i][0].' and '.$hotels[$j][0].'...'."\r\n"; $starDifference = $hotels[$i][1]-$hotels[$j][1]; $ratingToCompensate = $starDifference*$starCoef; $rating = $hotels[$i][2]+$ratingToCompensate; $ratingDifference = ($rating-$hotels[$j][2])*10; $priceToCompensate = $ratingDifference*$ratingCoef; $price = round($hotels[$i][3]-$priceToCompensate); echo $price.' VS '.$hotels[$j][3]."\r\n"; if ( $price < $hotels[$j][3] ) { echo $hotels[$i][0].' wins!'."\r\n"; $hotels[$i][4]++; } else { echo $hotels[$j][0].' wins!'."\r\n"; $hotels[$j][4]++; } echo "\r\n".'----------'."\r\n"; } } usort($hotels, function($hotelA, $hotelB){ return $hotelB[4]-$hotelA[4]; }); echo "\r\n".'----------'."\r\n"; echo 'Top:'."\r\n\r\n"; for ( $i=0; $i<count($hotels); $i++ ) { echo $hotels[$i][0].': '.$hotels[$i][4]."\r\n"; } echo "\r\n".'----------'."\r\n"; echo 'Finalists:'."\r\n\r\n"; for ( $i=0; $i<=1; $i++ ) { echo $hotels[$i][0]."\r\n"; }

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.60.0070.00716.61
8.3.50.0090.00821.97
8.3.40.0090.00619.06
8.3.30.0150.00319.32
8.3.20.0040.00420.46
8.3.10.0040.00423.48
8.3.00.0080.00019.25
8.2.180.0130.00718.54
8.2.170.0040.01122.96
8.2.160.0090.00620.43
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0030.00626.16
8.2.120.0040.00422.19
8.2.110.0100.00022.13
8.2.100.0040.00817.91
8.2.90.0000.00819.30
8.2.80.0030.00518.05
8.2.70.0000.00817.63
8.2.60.0100.00018.05
8.2.50.0000.00818.07
8.2.40.0050.00318.41
8.2.30.0000.00918.23
8.2.20.0050.00317.80
8.2.10.0040.00418.19
8.2.00.0070.00417.86
8.1.280.0150.00025.92
8.1.270.0030.00522.23
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0040.00422.20
8.1.230.0040.00821.04
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0000.00917.35
8.1.190.0030.00617.52
8.1.180.0050.00318.10
8.1.170.0030.01018.52
8.1.160.0070.00022.05
8.1.150.0050.00318.62
8.1.140.0000.00717.46
8.1.130.0030.00317.93
8.1.120.0050.00217.55
8.1.110.0000.00717.55
8.1.100.0000.00817.41
8.1.90.0040.00417.46
8.1.80.0030.00317.53
8.1.70.0070.00017.51
8.1.60.0040.00417.58
8.1.50.0000.00817.66
8.1.40.0030.00617.60
8.1.30.0090.00017.74
8.1.20.0000.00817.61
8.1.10.0040.00417.67
8.1.00.0080.00017.50
8.0.300.0020.00520.14
8.0.290.0000.00717.43
8.0.280.0030.00318.57
8.0.270.0040.00417.37
8.0.260.0030.00317.36
8.0.250.0000.00717.05
8.0.240.0030.00317.05
8.0.230.0050.00216.97
8.0.220.0050.00217.05
8.0.210.0000.00717.00
8.0.200.0030.00317.05
8.0.190.0040.00416.95
8.0.180.0040.00416.99
8.0.170.0000.00916.98
8.0.160.0040.00416.95
8.0.150.0080.00016.91
8.0.140.0040.00416.85
8.0.130.0000.00613.39
8.0.120.0060.00316.85
8.0.110.0000.00716.89
8.0.100.0000.00716.99
8.0.90.0000.00716.89
8.0.80.0060.01216.92
8.0.70.0040.00416.80
8.0.60.0040.00417.00
8.0.50.0040.00416.93
8.0.30.0050.01517.12
8.0.20.0060.01417.40
8.0.10.0000.00717.08
8.0.00.0170.01116.81
7.4.330.0030.00315.00
7.4.320.0030.00516.55
7.4.300.0030.00616.63
7.4.290.0040.00416.63
7.4.280.0030.00316.65
7.4.270.0030.00316.54
7.4.260.0000.00816.63
7.4.250.0040.00416.66
7.4.240.0050.00216.62
7.4.230.0050.00216.45
7.4.220.0140.00416.82
7.4.210.0080.00716.68
7.4.200.0050.00216.81
7.4.190.0030.00316.66
7.4.160.0090.00916.61
7.4.150.0090.00917.40
7.4.140.0150.00617.86
7.4.130.0090.00916.57
7.4.120.0100.01016.56
7.4.110.0160.00616.60
7.4.100.0030.01616.63
7.4.90.0150.00616.71
7.4.80.0130.01019.39
7.4.70.0100.00716.68
7.4.60.0180.00016.69
7.4.50.0040.00416.46
7.4.40.0060.01022.77
7.4.30.0070.01016.71
7.4.00.0070.01014.85
7.3.330.0060.00013.29
7.3.320.0000.00513.46
7.3.310.0050.00316.63
7.3.300.0070.00016.48
7.3.290.0090.00616.48
7.3.280.0090.01216.47
7.3.270.0080.01217.40
7.3.260.0080.00816.47
7.3.250.0100.01516.57
7.3.240.0170.00316.77
7.3.230.0150.00416.66
7.3.210.0030.01316.46
7.3.200.0130.01319.39
7.3.190.0040.01516.63
7.3.180.0150.00316.45
7.3.170.0100.00616.52
7.3.160.0130.00716.50
7.3.120.0070.01114.65
7.3.110.0080.00515.16
7.3.100.0080.00514.85
7.3.90.0100.00314.54
7.3.80.0100.00714.89
7.3.70.0030.01014.96
7.3.60.0030.01014.96
7.3.50.0130.00314.83
7.3.40.0060.00914.94
7.3.30.0070.00714.79
7.3.20.0090.00616.68
7.3.10.0050.01016.51
7.3.00.0060.00716.70
7.2.330.0070.01316.65
7.2.320.0150.00516.82
7.2.310.0130.00316.88
7.2.300.0040.01416.67
7.2.290.0060.01216.74
7.2.240.0000.01715.27
7.2.230.0030.01315.28
7.2.220.0060.00915.09
7.2.210.0030.01215.39
7.2.200.0070.01015.19
7.2.190.0120.00315.16
7.2.180.0090.00615.15
7.2.170.0090.00915.12
7.2.160.0090.00614.84
7.2.150.0050.00516.69
7.2.140.0070.01017.05
7.2.130.0100.00516.85
7.2.120.0100.00316.79
7.2.110.0090.00617.04
7.2.100.0070.00716.85
7.2.90.0050.00916.81
7.2.80.0030.01416.99
7.2.70.0080.00516.97
7.2.60.0080.00716.88
7.2.50.0040.00916.90
7.2.40.0100.00517.03
7.2.30.0080.00616.95
7.2.20.0090.00616.90
7.2.10.0080.00316.83
7.2.00.0060.01017.74
7.1.330.0060.00916.01
7.1.320.0090.00615.71
7.1.310.0030.00615.60
7.1.300.0040.01115.76
7.1.290.0100.00315.89
7.1.280.0120.00315.54
7.1.270.0080.00615.82
7.1.260.0070.00715.74
7.1.250.0110.00215.78
7.1.200.0130.00015.93
7.1.100.0000.01218.29
7.1.70.0040.00816.93
7.1.60.0180.00317.25
7.1.50.0060.01916.96
7.1.00.0070.07022.45
7.0.200.0040.01216.56
7.0.140.0070.07022.04
7.0.60.0100.05320.12
7.0.50.0070.07717.91
7.0.40.0100.08720.05
7.0.30.0330.03720.21
7.0.20.0270.08020.27
7.0.10.0030.06320.08
7.0.00.0070.04720.11
5.6.280.0070.07021.07
5.6.210.0100.09020.48
5.6.200.0030.08318.14
5.6.190.0070.04020.55
5.6.180.0230.04720.63
5.6.170.0300.07720.58
5.6.160.0030.04320.45
5.6.150.0070.03318.19
5.6.140.0070.04718.18
5.6.130.0070.05318.28
5.6.120.0170.05021.14
5.6.110.0070.04021.03
5.6.100.0100.08321.12
5.6.90.0030.09021.11
5.6.80.0030.04020.40
5.6.70.2900.02320.54
5.5.350.0100.04320.51
5.5.340.0170.06717.98
5.5.330.0000.08720.21
5.5.320.0700.06020.46
5.5.310.0100.04720.42
5.5.300.0070.03717.98
5.5.290.0000.07017.93
5.5.280.0030.04320.89
5.5.270.0100.08020.98
5.5.260.0000.04720.86
5.5.250.0130.04020.57
5.5.240.0270.07020.19
5.4.450.0700.05319.63
5.4.440.0900.05319.47
5.4.430.0170.06019.63
5.4.420.0900.07019.44
5.4.410.0170.07319.50
5.4.400.0700.05719.13
5.4.390.1070.08019.43
5.4.380.0500.06018.55
5.4.370.0200.07018.61
5.4.360.0170.06318.84
5.4.350.0170.06018.78
5.4.340.0200.05318.70
5.4.320.0100.04512.53
5.4.310.0080.04112.53
5.4.300.0070.04512.53
5.4.290.0080.04312.52
5.4.280.0110.04212.39
5.4.270.0120.04312.39
5.4.260.0120.06812.40
5.4.250.0090.05812.40
5.4.240.0090.04312.39
5.4.230.0170.07312.39
5.4.220.0110.05012.39
5.4.210.0250.11112.39
5.4.200.0260.09112.39
5.4.190.0130.04312.39
5.4.180.0080.04312.39
5.4.170.0100.06112.40
5.4.160.0190.06112.39
5.4.150.0140.06912.39
5.4.140.0080.03712.07
5.4.130.0110.04512.06
5.4.120.0130.04812.02
5.4.110.0090.03912.02
5.4.100.0120.03612.02
5.4.90.0090.04512.02
5.4.80.0080.06412.02
5.4.70.0080.05212.02
5.4.60.0100.05012.02
5.4.50.0130.04812.02
5.4.40.0110.04512.00
5.4.30.0040.03912.00
5.4.20.0090.03712.00
5.4.10.0070.03612.00
5.4.00.0050.04011.49
5.3.290.0060.04712.80
5.3.280.0080.04612.71
5.3.270.0080.03812.72
5.3.260.0070.03912.72
5.3.250.0090.03612.72
5.3.240.0070.03912.72
5.3.230.0070.04012.71
5.3.220.0140.05112.68
5.3.210.0220.04812.68
5.3.200.0100.05312.68
5.3.190.0100.05412.67
5.3.180.0150.04912.67
5.3.170.0110.05012.67
5.3.160.0070.04712.67
5.3.150.0190.06812.67
5.3.140.0130.05012.66
5.3.130.0080.05512.66
5.3.120.0370.05912.66
5.3.110.0100.05312.66
5.3.100.0070.04212.12
5.3.90.0080.04912.08
5.3.80.0040.04112.08
5.3.70.0090.03812.08
5.3.60.0080.04512.06
5.3.50.0040.05512.00
5.3.40.0110.05612.00
5.3.30.0060.05511.93
5.3.20.0120.05211.70
5.3.10.0080.05211.67
5.3.00.0070.05211.66
5.2.170.0100.0429.15
5.2.160.0070.0429.16
5.2.150.0060.0349.15
5.2.140.0040.0379.15
5.2.130.0070.0379.11
5.2.120.0110.0429.11
5.2.110.0100.0419.11
5.2.100.0070.0459.12
5.2.90.0100.0419.11
5.2.80.0120.0719.11
5.2.70.0080.0469.11
5.2.60.0100.0379.06
5.2.50.0100.0589.03
5.2.40.0060.0439.01
5.2.30.0070.0428.98
5.2.20.0110.0438.98
5.2.10.0070.0408.90
5.2.00.0090.0458.76
5.1.60.0050.0388.05
5.1.50.0090.0328.05
5.1.40.0090.0498.03
5.1.30.0070.0358.38
5.1.20.0080.0448.40
5.1.10.0040.0378.13
5.1.00.0100.0368.13
5.0.50.0070.0416.60
5.0.40.0050.0296.46
5.0.30.0060.0536.27
5.0.20.0050.0346.25
5.0.10.0050.0356.23
5.0.00.0040.0416.21
4.4.90.0100.0284.78
4.4.80.0070.0394.75
4.4.70.0100.0184.76
4.4.60.0040.0174.75
4.4.50.0050.0204.77
4.4.40.0040.0314.71
4.4.30.0050.0154.76
4.4.20.0060.0214.84
4.4.10.0030.0264.85
4.4.00.0040.0294.76
4.3.110.0050.0174.67
4.3.100.0040.0244.67
4.3.90.0050.0294.63
4.3.80.0030.0414.59
4.3.70.0110.0274.63
4.3.60.0040.0334.63
4.3.50.0060.0244.63
4.3.40.0100.0434.54
4.3.30.0040.0253.27
4.3.20.0040.0203.25
4.3.10.0040.0203.22
4.3.00.0170.01710.37

preferences:
45.38 ms | 401 KiB | 5 Q