3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Villa', 4, 8.5, 40398], ['Uvala', 4, 8.3, 52126], ['Valmar', 4, 8.6, 53104], ['Grand Hotel', 4, 8.1, 59340], ['Neptun', 4, 8.8, 61444], ['Valamar', 4, 8.7, 62365], ['Ariston', 5, 8.8, 68937], ['Rixos', 5, 8.5, 70370], ['Butique', 5, 9.2, 79818], ]; $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.0060.00916.63
8.3.50.0070.01222.13
8.3.40.0180.00018.98
8.3.30.0090.00619.26
8.3.20.0050.00320.46
8.3.10.0090.00023.57
8.3.00.0050.00319.51
8.2.180.0140.00416.88
8.2.170.0040.01122.96
8.2.160.0140.00020.35
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0030.00626.16
8.2.120.0040.00422.42
8.2.110.0110.00019.45
8.2.100.0040.00817.91
8.2.90.0060.00318.47
8.2.80.0000.00819.14
8.2.70.0000.01117.63
8.2.60.0050.00317.63
8.2.50.0080.00018.05
8.2.40.0030.00517.62
8.2.30.0080.00018.24
8.2.20.0040.00417.98
8.2.10.0050.00218.36
8.2.00.0070.00517.88
8.1.280.0120.00325.92
8.1.270.0080.00024.09
8.1.260.0030.00526.35
8.1.250.0090.00028.09
8.1.240.0060.00321.42
8.1.230.0090.00420.89
8.1.220.0090.00017.78
8.1.210.0050.00319.10
8.1.200.0030.00617.50
8.1.190.0070.00217.25
8.1.180.0000.00818.10
8.1.170.0040.00417.62
8.1.160.0070.00022.12
8.1.150.0000.00818.62
8.1.140.0000.00817.47
8.1.130.0040.00419.21
8.1.120.0050.00317.59
8.1.110.0040.00417.44
8.1.100.0000.00717.58
8.1.90.0050.00217.56
8.1.80.0000.00717.62
8.1.70.0070.00017.44
8.1.60.0000.00917.69
8.1.50.0030.00517.59
8.1.40.0060.00317.58
8.1.30.0050.00317.61
8.1.20.0040.00417.78
8.1.10.0060.00317.65
8.1.00.0040.00417.54
8.0.300.0070.00020.29
8.0.290.0060.00316.88
8.0.280.0070.00018.52
8.0.270.0030.00617.32
8.0.260.0000.00816.93
8.0.250.0040.00417.11
8.0.240.0000.00716.96
8.0.230.0070.00017.03
8.0.220.0030.00316.86
8.0.210.0040.00316.93
8.0.200.0000.00717.05
8.0.190.0000.00717.09
8.0.180.0080.00017.03
8.0.170.0000.00917.00
8.0.160.0070.00016.93
8.0.150.0000.00816.88
8.0.140.0000.00716.92
8.0.130.0030.00313.43
8.0.120.0040.00416.86
8.0.110.0000.00716.97
8.0.100.0040.00417.06
8.0.90.0000.00717.02
8.0.80.0150.00316.89
8.0.70.0040.00417.04
8.0.60.0060.00316.86
8.0.50.0000.00716.97
8.0.30.0110.01316.99
8.0.20.0110.01017.40
8.0.10.0040.00416.99
8.0.00.0090.01116.80
7.4.330.0000.00515.14
7.4.320.0040.00416.56
7.4.300.0030.00316.63
7.4.290.0020.00516.72
7.4.280.0000.00816.65
7.4.270.0000.00816.72
7.4.260.0000.00716.65
7.4.250.0040.00416.68
7.4.240.0020.00616.62
7.4.230.0050.00216.61
7.4.220.0060.01216.78
7.4.210.0080.01016.65
7.4.200.0070.00016.61
7.4.190.0000.00716.49
7.4.160.0100.00716.52
7.4.150.0080.01117.40
7.4.140.0100.00917.86
7.4.130.0080.01016.46
7.4.120.0090.01216.60
7.4.110.0030.01716.72
7.4.100.0070.01116.71
7.4.90.0140.01216.49
7.4.80.0160.00819.39
7.4.70.0030.01316.59
7.4.60.0140.00316.70
7.4.50.0000.00816.35
7.4.40.0060.00622.77
7.4.30.0150.00316.50
7.4.00.0080.00814.73
7.3.330.0070.00013.50
7.3.320.0000.00513.45
7.3.310.0030.00416.42
7.3.300.0040.00416.34
7.3.290.0100.01016.47
7.3.280.0100.00916.43
7.3.270.0140.00617.40
7.3.260.0150.00416.61
7.3.250.0150.00716.59
7.3.240.0150.01016.44
7.3.230.0140.00416.63
7.3.210.0100.00716.55
7.3.200.0080.01219.39
7.3.190.0100.01316.64
7.3.180.0070.00916.54
7.3.170.0080.00816.65
7.3.160.0100.00716.67
7.3.120.0120.00314.77
7.2.330.0110.00716.75
7.2.320.0120.00816.72
7.2.310.0100.01016.94
7.2.300.0160.00316.72
7.2.290.0000.02016.65
7.2.00.0000.01419.45
7.1.100.0000.01217.99
7.1.70.0030.00717.13
7.1.60.0150.00619.33
7.1.50.0140.02134.89
7.1.00.0030.08022.37
7.0.200.0120.00014.73
7.0.140.0070.07021.98
7.0.60.0000.08719.98
7.0.50.0030.04317.91
7.0.40.0170.06020.09
7.0.30.0230.04020.17
7.0.20.0230.05320.25
7.0.10.0070.06720.16
7.0.00.0070.07720.22
5.6.280.0030.07321.06
5.6.210.0070.08720.46
5.6.200.0130.07718.19
5.6.190.0130.07320.46
5.6.180.0230.08320.54
5.6.170.0330.07020.45
5.6.160.0100.08720.58
5.6.150.0070.09018.16
5.6.140.0130.08018.18
5.6.130.0030.07018.18
5.6.120.0070.04021.02
5.6.110.0030.09321.08
5.6.100.0100.08321.03
5.6.90.0130.07020.90
5.6.80.0230.06020.37
5.6.70.0970.04320.45
5.5.350.0100.09020.34
5.5.340.0070.08718.02
5.5.330.0070.05720.40
5.5.320.0100.07320.39
5.5.310.0270.07720.25
5.5.300.0200.04717.94
5.5.290.0030.05317.99
5.5.280.0170.07020.98
5.5.270.0130.07720.79
5.5.260.0000.08720.91
5.5.250.0100.07020.73
5.5.240.0170.07720.18
5.4.450.0600.06019.59
5.4.440.0670.06719.67
5.4.430.0130.05719.67
5.4.420.0900.05319.44
5.4.410.0930.08719.07
5.4.400.0970.05019.13
5.4.390.1070.06719.28
5.4.380.0270.05318.81
5.4.370.0300.05718.77
5.4.360.0530.05718.77
5.4.350.0330.06718.86
5.4.340.0270.06018.84
5.4.320.0120.04312.53
5.4.310.0100.04712.53
5.4.300.0120.04012.53
5.4.290.0050.04312.53
5.4.280.0170.09112.40
5.4.270.0060.04512.40
5.4.260.0110.04312.39
5.4.250.0110.05612.40
5.4.240.0080.05712.40
5.4.230.0070.05412.39
5.4.220.0060.04512.39
5.4.210.0060.04412.39
5.4.200.0200.12112.39
5.4.190.0090.06712.39
5.4.180.0100.04512.39
5.4.170.0080.04712.39
5.4.160.0120.04112.39
5.4.150.0200.04212.39
5.4.140.0210.06912.07
5.4.130.0960.23112.07
5.4.120.0260.11512.02
5.4.110.0240.06112.01
5.4.100.0160.07512.02
5.4.90.0110.05812.02
5.4.80.0240.14412.01
5.4.70.0510.08212.01
5.4.60.0180.08412.01
5.4.50.0270.11912.02
5.4.40.0090.07512.00
5.4.30.0190.10712.00
5.4.20.0150.08512.00
5.4.10.0140.06512.00
5.4.00.0200.10911.49
5.3.290.0070.05212.80
5.3.280.0360.13612.71
5.3.270.0140.10612.73
5.3.260.0350.09012.72
5.3.250.0230.06312.72
5.3.240.0200.07412.72
5.3.230.0130.08412.71
5.3.220.0400.09412.68
5.3.210.0280.09512.68
5.3.200.0250.10312.68
5.3.190.0240.09112.68
5.3.180.0160.06912.67
5.3.170.0320.12912.67
5.3.160.0300.07312.67
5.3.150.0140.04412.67
5.3.140.0230.07112.66
5.3.130.0230.10212.66
5.3.120.0200.08412.66
5.3.110.0140.05612.66
5.3.100.0300.11912.12
5.3.90.0160.05612.08
5.3.80.0260.07312.08
5.3.70.0120.04412.07
5.3.60.0280.10312.06
5.3.50.0110.09212.00
5.3.40.0160.06512.00
5.3.30.0230.06111.93
5.3.20.0250.07311.70
5.3.10.0170.07111.67
5.3.00.0180.06811.66
5.2.170.0280.0909.15
5.2.160.0190.0559.15
5.2.150.0110.0969.15
5.2.140.0220.0809.15
5.2.130.0250.0829.11
5.2.120.0170.0719.11
5.2.110.0120.0559.11
5.2.100.0060.0579.11
5.2.90.0130.0659.11
5.2.80.0070.0609.11
5.2.70.0060.0419.11
5.2.60.0110.0779.06
5.2.50.0180.0649.03
5.2.40.0100.0549.00
5.2.30.0100.0428.98
5.2.20.0270.0568.98
5.2.10.0310.0528.90
5.2.00.0260.0838.76
5.1.60.0130.0558.04
5.1.50.0360.0918.05
5.1.40.0070.0388.03
5.1.30.0170.0548.38
5.1.20.0330.0858.40
5.1.10.0180.0898.12
5.1.00.0100.0598.13
5.0.50.0110.0366.60
5.0.40.0180.0566.46
5.0.30.0090.1086.27
5.0.20.0110.0346.24
5.0.10.0050.0456.22
5.0.00.0070.0616.21
4.4.90.0170.0384.78
4.4.80.0040.0444.75
4.4.70.0080.0454.76
4.4.60.0070.0444.76
4.4.50.0110.0434.77
4.4.40.0130.0594.71
4.4.30.0060.0324.76
4.4.20.0100.0344.84
4.4.10.0040.0484.84
4.4.00.0080.0504.76
4.3.110.0140.0374.67
4.3.100.0080.0414.66
4.3.90.0090.0444.64
4.3.80.0040.0494.59
4.3.70.0090.0364.63
4.3.60.0190.0724.63
4.3.50.0030.0654.63
4.3.40.0100.0604.54
4.3.30.0060.0203.27
4.3.20.0050.0503.25
4.3.10.0070.0293.22
4.3.00.0200.03310.37

preferences:
46.54 ms | 401 KiB | 5 Q