3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Cala', 3, 8.7, 6000], ['Ocean', 3, 8.2, 6150], ['Orchid', 3, 8.0, 7200], ['Ya', 3, 8.7, 6950], ['Chaba', 3, 8.2, 7120], ]; var_dump($hotels); $totalHotelsNumber = 2; $starCoef = 0.2; $ratingCoef = 2000; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[4] = 0; } for ( $i=0; $i<count($hotels); $i++ ) { for ( $j=$i+1; $j<count($hotels); $j++ ) { echo $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]; $priceToCompensate = $ratingDifference*$ratingCoef; $price = $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.01017.00
8.3.50.0130.00817.37
8.3.40.0030.01519.02
8.3.30.0110.00418.83
8.3.20.0090.00018.95
8.3.10.0090.00020.61
8.3.00.0030.00517.75
8.2.180.0090.00616.75
8.2.170.0220.00022.96
8.2.160.0200.00322.15
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0030.00526.16
8.2.120.0000.00819.77
8.2.110.0130.01021.04
8.2.100.0000.01218.03
8.2.90.0000.01019.34
8.2.80.0030.00519.34
8.2.70.0060.00317.63
8.2.60.0030.00618.05
8.2.50.0000.00818.07
8.2.40.0040.00418.34
8.2.30.0040.00418.09
8.2.20.0090.00017.75
8.2.10.0080.00317.91
8.2.00.0080.00317.95
8.1.280.0000.01425.92
8.1.270.0040.00424.66
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0080.01223.96
8.1.230.0070.00717.48
8.1.220.0000.00817.76
8.1.210.0000.00818.89
8.1.200.0030.00617.36
8.1.190.0000.00817.30
8.1.180.0000.00818.10
8.1.170.0080.00018.79
8.1.160.0000.00718.80
8.1.150.0030.00618.71
8.1.140.0040.00417.34
8.1.130.0070.00017.91
8.1.120.0080.00017.55
8.1.110.0000.00817.39
8.1.100.0040.00417.38
8.1.90.0070.00017.44
8.1.80.0050.00217.50
8.1.70.0000.00717.50
8.1.60.0060.00317.49
8.1.50.0000.00817.53
8.1.40.0060.00317.49
8.1.30.0060.00317.63
8.1.20.0030.00517.61
8.1.10.0040.00417.57
8.1.00.0050.00317.47
8.0.300.0000.00719.98
8.0.290.0040.00416.63
8.0.280.0070.00018.48
8.0.270.0070.00017.21
8.0.260.0070.00016.83
8.0.250.0040.00417.08
8.0.240.0030.00717.00
8.0.230.0040.00417.07
8.0.220.0000.00717.02
8.0.210.0030.00616.88
8.0.200.0030.00517.05
8.0.190.0040.00416.93
8.0.180.0040.00417.07
8.0.170.0040.00717.05
8.0.160.0050.00216.96
8.0.150.0050.00316.93
8.0.140.0070.00616.86
8.0.130.0000.00613.43
8.0.120.0000.00916.94
8.0.110.0050.00217.00
8.0.100.0000.00716.81
8.0.90.0040.00417.11
8.0.80.0160.00017.04
8.0.70.0050.00317.00
8.0.60.0040.00417.02
8.0.50.0030.00517.02
8.0.30.0130.00717.21
8.0.20.0140.00417.31
8.0.10.0040.00417.18
8.0.00.0150.00716.75
7.4.330.0000.00512.93
7.4.320.0000.00616.53
7.4.300.0050.00316.54
7.4.290.0000.00716.70
7.4.280.0080.00316.68
7.4.270.0070.00016.53
7.4.260.0000.00613.38
7.4.250.0030.00616.51
7.4.240.0070.00016.53
7.4.230.0030.00316.48
7.4.220.0110.01516.56
7.4.210.0070.01016.66
7.4.200.0040.00416.67
7.4.190.0030.00516.50
7.4.160.0120.00716.48
7.4.150.0100.01016.80
7.4.140.0190.00916.60
7.4.130.0120.00916.67
7.4.120.0090.01116.58
7.4.110.0070.01316.37
7.4.100.0130.00416.57
7.4.90.0160.00316.77
7.4.80.0100.01016.47
7.4.70.0080.01116.34
7.4.60.0110.00716.61
7.4.50.0050.00216.34
7.4.40.0080.00416.66
7.4.30.0150.00316.56
7.4.00.0050.01115.01
7.3.330.0000.00613.43
7.3.320.0030.00313.30
7.3.310.0000.00716.36
7.3.300.0030.00416.48
7.3.290.0000.01616.46
7.3.280.0100.00916.43
7.3.270.0060.01116.43
7.3.260.0110.01116.55
7.3.250.0160.00616.56
7.3.240.0120.00616.62
7.3.230.0110.00716.43
7.3.210.0080.01116.67
7.3.200.0070.01119.39
7.3.190.0100.01316.64
7.3.180.0140.00616.65
7.3.170.0030.01416.58
7.3.160.0040.01316.45
7.3.120.0090.00615.12
7.3.110.0100.00714.86
7.3.100.0030.01315.00
7.3.90.0070.00715.18
7.3.80.0130.00314.91
7.3.70.0040.00414.71
7.3.60.0040.01514.94
7.3.50.0070.01114.97
7.3.40.0090.00614.80
7.3.30.0100.00714.99
7.3.20.0130.00316.89
7.3.10.0030.01016.82
7.3.00.0080.00516.71
7.2.330.0080.01116.71
7.2.320.0120.00916.84
7.2.310.0070.01716.79
7.2.300.0090.00816.92
7.2.290.0100.00716.53
7.2.250.0070.01115.12
7.2.240.0100.01015.06
7.2.230.0040.01115.11
7.2.220.0130.00914.84
7.2.210.0100.00614.94
7.2.200.0100.00315.24
7.2.190.0070.00715.00
7.2.180.0090.00615.16
7.2.170.0000.01014.96
7.2.00.0030.01019.63
7.1.330.0100.00615.92
7.1.320.0060.00315.98
7.1.310.0070.00715.69
7.1.300.0110.00815.77
7.1.290.0070.01015.92
7.1.280.0070.00715.65
7.1.270.0110.00315.60
7.1.260.0070.00315.66
7.1.100.0030.00918.37
7.1.70.0040.00417.07
7.1.60.0060.01619.40
7.1.50.0230.01334.56
7.1.00.0030.04322.44
7.0.200.0040.00416.97
7.0.140.0030.07322.18
7.0.120.0100.06322.04
7.0.60.0000.04319.83
7.0.50.0130.06018.00
7.0.40.0070.08317.75
7.0.30.0030.04317.82
7.0.20.0030.04317.76
7.0.10.0030.04317.78
7.0.00.0130.04317.85
5.6.280.0000.07320.79
5.6.210.0130.07320.77
5.6.200.0170.07018.29
5.6.190.0170.07718.24
5.6.180.0030.09018.13
5.6.170.0070.04018.20
5.6.160.0100.04018.29
5.6.150.0030.05018.27
5.6.140.0030.07318.21
5.6.130.0100.05018.18
5.6.120.0030.06718.26
5.6.110.0070.08718.28
5.6.100.0100.04318.28
5.6.90.0100.05018.27
5.6.80.0130.07017.54
5.6.70.0030.04317.55
5.6.60.0030.04317.55
5.6.50.0100.07317.53
5.6.40.0100.04017.54
5.6.30.0070.04717.55
5.6.20.0000.07717.50
5.6.10.0070.07717.53
5.6.00.0100.04017.63
5.5.350.0100.06320.45
5.5.340.0030.08017.96
5.5.330.0130.07318.04
5.5.320.0030.04018.07
5.5.310.0000.04718.08
5.5.300.0070.05317.98
5.5.290.0070.04317.98
5.5.280.0100.06717.98
5.5.270.0070.08718.04
5.5.260.0070.06317.95
5.5.250.0070.08317.89
5.5.240.0070.06017.33
5.5.230.0070.03717.34
5.5.220.0000.08017.42
5.5.210.0130.03717.34
5.5.200.0000.05717.32
5.5.190.0100.04317.34
5.5.180.0130.04317.42
5.5.160.0070.04317.29
5.5.150.0000.05317.42
5.5.140.0070.07317.39
5.5.130.0100.07317.39
5.5.120.0070.07717.39
5.5.110.0070.06317.43
5.5.100.0030.04017.33
5.5.90.0070.04317.33
5.5.80.0070.03317.27
5.5.70.0030.04017.28
5.5.60.0000.03717.19
5.5.50.0030.03317.20
5.5.40.0030.03717.21
5.5.30.0070.03317.28
5.5.20.0000.04317.23
5.5.10.0030.03717.25
5.5.00.0030.03717.16
5.4.450.0130.08319.45
5.4.440.0070.07719.29
5.4.430.0030.05719.37
5.4.420.0000.04719.45
5.4.410.0070.04719.33
5.4.400.0100.05019.14
5.4.390.0130.03018.96
5.4.380.0130.04019.27
5.4.370.0030.06019.13
5.4.360.0200.06719.02
5.4.350.0070.07719.11
5.4.340.0070.07718.99
5.4.320.0170.06319.02
5.4.310.0100.07719.02
5.4.300.0130.05719.05
5.4.290.0000.08018.95
5.4.280.0070.08019.14
5.4.270.0130.07318.95
5.4.260.0030.03719.12
5.4.250.0070.03318.88
5.4.240.0030.03719.13
5.4.230.0030.03718.95
5.4.220.0000.04018.98
5.4.210.0070.03319.03
5.4.200.0030.03719.01
5.4.190.0030.03719.09
5.4.180.0270.02319.26
5.4.170.0030.04719.04
5.4.160.0030.03719.09
5.4.150.0030.03719.02
5.4.140.0070.03716.46
5.4.130.0030.05016.40
5.4.120.0030.03716.40
5.4.110.0000.03716.46
5.4.100.0030.03316.35
5.4.90.0070.03016.34
5.4.80.0030.03316.44
5.4.70.0070.03016.23
5.4.60.0030.04316.43
5.4.50.0030.04316.38
5.4.40.0130.03316.45
5.4.30.0070.03016.37
5.4.20.0000.03716.35
5.4.10.0000.03716.43
5.4.00.0070.03315.83
5.3.290.0030.07314.63
5.3.280.0000.04014.68
5.3.270.0000.04014.57
5.3.260.0030.03714.57
5.3.250.0030.03314.52
5.3.240.0030.03714.55
5.3.230.0000.04014.57
5.3.220.0000.04014.43
5.3.210.0030.03714.39
5.3.200.0070.03314.51
5.3.190.0070.03714.54
5.3.180.0170.05014.42
5.3.170.0030.04014.53
5.3.160.0000.03714.39
5.3.150.0070.03314.53
5.3.140.0030.04014.49
5.3.130.0030.03714.63
5.3.120.0070.03314.54
5.3.110.0030.03714.49
5.3.100.0000.03714.00
5.3.90.0100.07313.84
5.3.80.0030.04713.79
5.3.70.0030.04014.00
5.3.60.0030.07313.90
5.3.50.0030.05713.91
5.3.40.0130.05313.89
5.3.30.0100.05013.82
5.3.20.0030.04713.67
5.3.10.0130.03713.73
5.3.00.0070.05013.59
5.2.170.0030.03311.07
5.2.160.0070.02711.14
5.2.150.0000.04011.29
5.2.140.0100.05311.14
5.2.130.0030.06710.93
5.2.120.0070.06011.08
5.2.110.0030.05711.06
5.2.100.0070.06011.08
5.2.90.0000.05710.93
5.2.80.0000.06310.92
5.2.70.0070.06011.23
5.2.60.0100.05711.02
5.2.50.0000.05310.91
5.2.40.0000.04011.00
5.2.30.0030.04010.90
5.2.20.0130.05310.88
5.2.10.0070.06010.78
5.2.00.0000.04710.73
5.1.60.0030.0579.96
5.1.50.0130.04310.14
5.1.40.0030.0579.89
5.1.30.0070.05310.32
5.1.20.0030.03310.35
5.1.10.0070.0409.90
5.1.00.0030.04010.21
5.0.50.0030.0478.99
5.0.40.0030.0378.99
5.0.30.0030.0578.99
5.0.20.0030.0478.99
5.0.10.0100.0338.99
5.0.00.0100.0238.99
4.4.90.0030.0338.99
4.4.80.0070.0278.99
4.4.70.0000.0338.99
4.4.60.0000.0308.99
4.4.50.0030.0238.99
4.4.40.0000.0578.99
4.4.30.0070.0338.99
4.4.20.0030.0278.99
4.4.10.0000.0408.99
4.4.00.0070.0408.99
4.3.110.0030.0178.99
4.3.100.0000.0378.99
4.3.90.0030.0378.99
4.3.80.0000.0408.99
4.3.70.0030.0378.99
4.3.60.0030.0378.99
4.3.50.0100.0208.99
4.3.40.0030.0408.99
4.3.30.0000.0378.99
4.3.20.0000.0408.99
4.3.10.0000.0338.99
4.3.00.0000.0378.99

preferences:
41.7 ms | 401 KiB | 5 Q