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], ]; $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.' - '.$hotels[$j][0]; 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.0090.00618.55
8.3.50.0100.01222.17
8.3.40.0120.00318.83
8.3.30.0110.00418.79
8.3.20.0080.00018.82
8.3.10.0080.00020.66
8.3.00.0080.00021.69
8.2.180.0110.00716.88
8.2.170.0100.00622.96
8.2.160.0040.01120.39
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00319.48
8.2.110.0030.00722.30
8.2.100.0090.00317.97
8.2.90.0050.00319.26
8.2.80.0040.00418.05
8.2.70.0000.00817.61
8.2.60.0050.00317.93
8.2.50.0030.00518.07
8.2.40.0000.00818.16
8.2.30.0000.00819.96
8.2.20.0080.00017.70
8.2.10.0030.00617.85
8.2.00.0000.00917.90
8.1.280.0100.01025.92
8.1.270.0070.00023.99
8.1.260.0090.00026.35
8.1.250.0080.00028.09
8.1.240.0000.00922.61
8.1.230.0080.00421.00
8.1.220.0030.00618.77
8.1.210.0070.00318.98
8.1.200.0030.01017.36
8.1.190.0000.00817.53
8.1.180.0050.00318.10
8.1.170.0060.00318.84
8.1.160.0020.00518.97
8.1.150.0030.00518.73
8.1.140.0040.00417.49
8.1.130.0000.00817.97
8.1.120.0080.00017.55
8.1.110.0090.00017.46
8.1.100.0090.00017.53
8.1.90.0040.00417.47
8.1.80.0020.00517.45
8.1.70.0040.00417.39
8.1.60.0030.00517.51
8.1.50.0030.00517.43
8.1.40.0050.00317.48
8.1.30.0000.00817.70
8.1.20.0030.00517.72
8.1.10.0030.00517.58
8.1.00.0110.00017.46
8.0.300.0040.00419.91
8.0.290.0040.00418.61
8.0.280.0040.00418.40
8.0.270.0000.00717.19
8.0.260.0070.00016.90
8.0.250.0080.00017.10
8.0.240.0040.00417.00
8.0.230.0000.00816.92
8.0.220.0040.00417.02
8.0.210.0050.00316.88
8.0.200.0040.00417.13
8.0.190.0000.00816.95
8.0.180.0030.00516.92
8.0.170.0030.00617.05
8.0.160.0030.00517.05
8.0.150.0030.00617.04
8.0.140.0120.00016.88
8.0.130.0050.00013.42
8.0.120.0080.00016.91
8.0.110.0000.00916.87
8.0.100.0000.00717.02
8.0.90.0070.00017.05
8.0.80.0120.00317.04
8.0.70.0000.00816.78
8.0.60.0030.00516.87
8.0.50.0040.00417.03
8.0.30.0120.00717.31
8.0.20.0110.00817.40
8.0.10.0040.00417.09
8.0.00.0090.01316.79
7.4.330.0030.00314.78
7.4.320.0000.00716.46
7.4.300.0030.00316.60
7.4.290.0000.00716.66
7.4.280.0040.00416.52
7.4.270.0000.00716.70
7.4.260.0000.00513.34
7.4.250.0050.00216.51
7.4.240.0000.00716.57
7.4.230.0040.00416.73
7.4.220.0060.01216.49
7.4.210.0080.00916.59
7.4.200.0000.00816.71
7.4.190.0070.00016.40
7.4.160.0170.00016.62
7.4.150.0090.01017.40
7.4.140.0120.00717.86
7.4.130.0080.01016.48
7.4.120.0050.01216.64
7.4.110.0100.00716.44
7.4.100.0070.01016.62
7.4.90.0140.00316.48
7.4.80.0110.00719.37
7.4.70.0040.01516.49
7.4.60.0060.01016.40
7.4.50.0000.00616.42
7.4.40.0000.01222.27
7.4.30.0080.01416.68
7.4.00.0030.01314.96
7.3.330.0060.00013.47
7.3.320.0060.00013.22
7.3.310.0080.00016.48
7.3.300.0030.00316.34
7.3.290.0080.00816.48
7.3.280.0130.00716.46
7.3.270.0110.00617.40
7.3.260.0150.00818.24
7.3.250.0110.01016.42
7.3.240.0140.00316.72
7.3.230.0140.00316.53
7.3.210.0070.01016.45
7.3.200.0170.00719.39
7.3.190.0090.00916.45
7.3.180.0060.01116.54
7.3.170.0090.00916.49
7.3.160.0150.00916.70
7.3.120.0070.01014.79
7.3.10.0070.01016.61
7.3.00.0160.00616.31
7.2.330.0120.00616.54
7.2.320.0100.00716.95
7.2.310.0100.01016.80
7.2.300.0140.01016.50
7.2.290.0080.00816.91
7.2.130.0130.00616.75
7.2.120.0000.01916.50
7.2.110.0090.00916.78
7.2.100.0190.00016.68
7.2.90.0180.00916.59
7.2.80.0050.00816.66
7.2.70.0040.00417.09
7.2.60.0160.00616.41
7.2.50.0140.00416.76
7.2.40.0060.00916.71
7.2.30.0060.01616.98
7.2.20.0110.00316.78
7.2.10.0040.00716.85
7.2.00.0020.01318.13
7.1.250.0140.00315.66
7.1.100.0030.01017.99
7.1.70.0070.00316.87
7.1.60.0070.01819.40
7.1.50.0060.01516.95
7.1.00.0000.04322.44
7.0.200.0050.00316.77
7.0.140.0170.06021.97
7.0.70.0030.08721.73
7.0.60.0100.05721.71
7.0.50.0070.08722.19
7.0.40.0000.06319.99
7.0.30.0030.08020.14
7.0.20.0000.06320.04
7.0.10.0030.04719.94
7.0.00.0030.04320.03
5.6.280.0030.07321.12
5.6.220.0000.09020.54
5.6.210.0100.06020.77
5.6.200.0070.09020.97
5.6.190.0170.06721.11
5.6.180.0070.06721.18
5.6.170.0030.06721.10
5.6.160.0030.04021.04
5.6.150.0000.04321.05
5.6.140.0000.08721.05
5.6.130.0030.06021.18
5.6.120.0130.07721.01
5.6.110.0100.08020.92
5.6.100.0070.08320.94
5.6.90.0000.09021.03
5.6.80.0030.08320.51
5.6.70.0030.06020.50
5.6.60.0170.06720.43
5.6.50.0000.08020.41
5.6.40.0070.07720.44
5.6.30.0030.08320.32
5.6.20.0100.07720.41
5.6.10.0070.07320.43
5.6.00.0170.05720.40
5.5.360.0000.07720.43
5.5.350.0070.08020.44
5.5.340.0000.06320.89
5.5.330.0100.07320.82
5.5.320.0130.07720.77
5.5.310.0100.06720.83
5.5.300.0030.05720.77
5.5.290.0030.09020.82
5.5.280.0030.08720.74
5.5.270.0070.08020.82
5.5.260.0070.07320.77
5.5.250.0030.08020.67
5.5.240.0100.07320.31
5.5.230.0130.07320.21
5.5.220.0070.07720.19
5.5.210.0070.08320.27
5.5.200.0070.06720.29
5.5.190.0170.04720.01
5.5.180.0000.06320.27
5.5.160.0100.04320.23
5.5.150.0030.03720.18
5.5.140.0030.03720.11
5.5.130.0000.04020.09
5.5.120.0030.04320.12
5.5.110.0000.04720.24
5.5.100.0030.03720.09
5.5.90.0000.04020.07
5.5.80.0000.04320.14
5.5.70.0100.03320.08
5.5.60.0030.03720.13
5.5.50.0030.05720.00
5.5.40.0030.03719.96
5.5.30.0030.03720.06
5.5.20.0000.04019.97
5.5.10.0070.04020.00
5.5.00.0030.04020.03
5.4.450.0100.06719.51
5.4.440.0030.08719.48
5.4.430.0070.07319.45
5.4.420.0070.07019.37
5.4.410.0070.08019.32
5.4.400.0030.06319.23
5.4.390.0130.07019.04
5.4.380.0100.06019.16
5.4.370.0070.07719.21
5.4.360.0030.05319.18
5.4.350.0030.07019.13
5.4.340.0070.07719.23
5.4.320.0070.03719.04
5.4.310.0030.03718.95
5.4.300.0030.05018.87
5.4.290.0130.06019.23
5.4.280.0000.04019.04
5.4.270.0030.03719.14
5.4.260.0070.03319.13
5.4.250.0000.04019.15
5.4.240.0000.04019.12
5.4.230.0000.04019.13
5.4.220.0030.03718.89
5.4.210.0030.05719.18
5.4.200.0030.05318.95
5.4.190.0030.03719.11
5.4.180.0000.04019.23
5.4.170.0030.06719.02
5.4.160.0000.04019.00
5.4.150.0000.04019.01
5.4.140.0030.03316.41
5.4.130.0000.04016.43
5.4.120.0000.04016.50
5.4.110.0030.03316.36
5.4.100.0000.04716.34
5.4.90.0030.03316.39
5.4.80.0070.03016.41
5.4.70.0030.03316.28
5.4.60.0030.03716.31
5.4.50.0030.06316.45
5.4.40.0030.04316.54
5.4.30.0030.03316.47
5.4.20.0000.04316.31
5.4.10.0000.03716.42
5.4.00.0100.02715.77
5.3.290.0000.04014.64
5.3.280.0000.04714.59
5.3.270.0030.03714.47
5.3.260.0130.02714.42
5.3.250.0030.03314.47
5.3.240.0030.03314.57
5.3.230.0030.03714.57
5.3.220.0030.07314.52
5.3.210.0000.04014.43
5.3.200.0030.05714.51
5.3.190.0030.03714.40
5.3.180.0070.07014.55
5.3.170.0070.03714.40
5.3.160.0030.03314.57
5.3.150.0030.03314.40
5.3.140.0030.03314.54
5.3.130.0000.04014.41
5.3.120.0000.04014.50
5.3.110.0000.04014.55
5.3.100.0030.06313.95
5.3.90.0000.04013.96
5.3.80.0070.03313.97
5.3.70.0070.04313.89
5.3.60.0030.03313.94
5.3.50.0000.03313.89
5.3.40.0030.03313.90
5.3.30.0000.03713.82
5.3.20.0030.03313.46
5.3.10.0000.02713.52
5.3.00.0000.05013.54
5.2.170.0000.04712.19
5.2.160.0030.03012.19
5.2.150.0000.03012.19
5.2.140.0000.03012.19
5.2.130.0000.03012.19
5.2.120.0030.02712.19
5.2.110.0000.02712.19
5.2.100.0000.05712.19
5.2.90.0000.04312.19
5.2.80.0030.04712.19
5.2.70.0000.05312.19
5.2.60.0000.03312.19
5.2.50.0070.06012.19
5.2.40.0000.05712.19
5.2.30.0100.05012.19
5.2.20.0000.06312.19
5.2.10.0000.05312.19
5.2.00.0070.06012.19
5.1.60.0000.05012.19
5.1.50.0000.04312.19
5.1.40.0030.05012.19
5.1.30.0000.05712.19
5.1.20.0100.04312.19
5.1.10.0070.05012.19
5.1.00.0000.03712.19
5.0.50.0070.04012.19
5.0.40.0030.04712.19
5.0.30.0070.05012.19
5.0.20.0000.04712.19
5.0.10.0100.03712.19
5.0.00.0000.06012.19
4.4.90.0000.01712.19
4.4.80.0000.03712.19
4.4.70.0000.03012.19
4.4.60.0030.02312.19
4.4.50.0000.03712.19
4.4.40.0000.04712.19
4.4.30.0000.03312.19
4.4.20.0030.03312.19
4.4.10.0030.03312.19
4.4.00.0000.05712.19
4.3.110.0000.03312.19
4.3.100.0000.03712.19
4.3.90.0000.04312.19
4.3.80.0000.05712.19
4.3.70.0000.03712.19
4.3.60.0030.03312.19
4.3.50.0070.03012.19
4.3.40.0000.05012.19
4.3.30.0070.03012.19
4.3.20.0000.03012.19
4.3.10.0000.03012.19
4.3.00.0000.03712.19

preferences:
45.93 ms | 401 KiB | 5 Q