3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Premier', 3, 8.1, 12472], ['Premier Park', 3, 8.0, 14525], ['Premier Airoport', 3, 8.4, 17390], ['Porpoints', 4, 8.0, 19195], ['arabiain', 4, 8.1, 20749], ['La meridian', 5, 8.4, 21147], ['Sheraton', 5, 8.8, 22351], ['Savoy', 0, 8.2, 22438], ['Hiyat', 4, 8.5, 23240], ['Hilton', 5, 8.2, 24000], ]; $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.70.0170.00016.75
8.3.60.0090.00617.00
8.3.50.0140.00521.16
8.3.40.0040.01518.82
8.3.30.0070.00719.27
8.3.20.0030.00520.41
8.3.10.0040.00423.65
8.3.00.0060.00319.38
8.2.180.0110.00418.29
8.2.170.0130.00922.96
8.2.160.0140.00020.38
8.2.150.0050.00324.18
8.2.140.0030.00624.66
8.2.130.0080.00026.16
8.2.120.0040.00422.20
8.2.110.0000.00922.20
8.2.100.0040.00817.91
8.2.90.0050.00719.20
8.2.80.0040.00418.02
8.2.70.0090.00017.63
8.2.60.0040.00418.05
8.2.50.0000.00818.07
8.2.40.0000.00818.34
8.2.30.0030.00618.30
8.2.20.0040.00417.80
8.2.10.0000.00718.13
8.2.00.0070.00217.80
8.1.280.0070.00725.92
8.1.270.0040.00422.20
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0060.00323.95
8.1.230.0040.00819.32
8.1.220.0080.00017.89
8.1.210.0030.00618.77
8.1.200.0060.00317.60
8.1.190.0040.00417.78
8.1.180.0000.00818.10
8.1.170.0090.00018.76
8.1.160.0070.00022.12
8.1.150.0040.00418.72
8.1.140.0090.00017.52
8.1.130.0030.00318.06
8.1.120.0050.00217.61
8.1.110.0040.00417.56
8.1.100.0040.00417.64
8.1.90.0040.00417.59
8.1.80.0000.00717.61
8.1.70.0030.00517.53
8.1.60.0000.00817.70
8.1.50.0040.00417.56
8.1.40.0040.00417.53
8.1.30.0030.00617.69
8.1.20.0040.00417.65
8.1.10.0080.00017.55
8.1.00.0030.00517.64
8.0.300.0000.00718.77
8.0.290.0060.00317.18
8.0.280.0000.00718.45
8.0.270.0000.00717.30
8.0.260.0060.00017.49
8.0.250.0000.00717.10
8.0.240.0040.00417.05
8.0.230.0020.00517.07
8.0.220.0070.00017.03
8.0.210.0020.00517.06
8.0.200.0020.00517.12
8.0.190.0040.00416.97
8.0.180.0040.00416.98
8.0.170.0040.00416.90
8.0.160.0030.00316.95
8.0.150.0040.00416.98
8.0.140.0040.00416.93
8.0.130.0030.00313.43
8.0.120.0050.00317.01
8.0.110.0080.00016.92
8.0.100.0000.00716.87
8.0.90.0050.00316.85
8.0.80.0100.00917.07
8.0.70.0000.00716.80
8.0.60.0000.00816.84
8.0.50.0000.00716.98
8.0.30.0080.01417.17
8.0.20.0150.00417.43
8.0.10.0040.00417.07
8.0.00.0140.00516.93
7.4.330.0030.00315.09
7.4.320.0070.00016.58
7.4.300.0060.00016.72
7.4.290.0000.00716.61
7.4.280.0000.00816.61
7.4.270.0040.00416.70
7.4.260.0030.00516.70
7.4.250.0080.00016.70
7.4.240.0020.00516.69
7.4.230.0040.00416.73
7.4.220.0130.00416.68
7.4.210.0080.00816.70
7.4.200.0000.00716.83
7.4.190.0000.00816.67
7.4.160.0100.00616.48
7.4.150.0240.00317.40
7.4.140.0090.01017.86
7.4.130.0140.00716.62
7.4.120.0120.00716.78
7.4.110.0090.00916.55
7.4.100.0190.00416.41
7.4.90.0150.00816.73
7.4.80.0140.00819.39
7.4.70.0110.00616.75
7.4.60.0080.01016.61
7.4.50.0040.00416.36
7.4.40.0090.00622.77
7.4.30.0100.00716.63
7.4.10.0180.00014.93
7.4.00.0070.00814.95
7.3.330.0000.00713.25
7.3.320.0000.00513.32
7.3.310.0070.00016.31
7.3.300.0040.00416.53
7.3.290.0120.00616.48
7.3.280.0110.01016.46
7.3.270.0100.00917.40
7.3.260.0150.00316.66
7.3.250.0120.01016.57
7.3.240.0100.01016.68
7.3.230.0090.00916.63
7.3.210.0070.01016.59
7.3.200.0130.00719.39
7.3.190.0220.00016.44
7.3.180.0030.01516.76
7.3.170.0150.00816.52
7.3.160.0140.00416.53
7.3.130.0060.01314.93
7.3.120.0080.00814.76
7.3.110.0080.00814.56
7.3.100.0050.01014.94
7.3.90.0050.00914.76
7.3.80.0020.01214.84
7.3.70.0080.00714.90
7.3.60.0060.00614.87
7.3.50.0050.01014.86
7.3.40.0060.00514.80
7.3.30.0060.00814.63
7.3.20.0060.00716.47
7.3.10.0080.00516.57
7.3.00.0010.01116.55
7.2.330.0040.01816.90
7.2.320.0130.00516.68
7.2.310.0070.01516.74
7.2.300.0090.00916.78
7.2.290.0170.00317.02
7.2.260.0060.01215.04
7.2.250.0080.01115.13
7.2.240.0050.01315.05
7.2.230.0080.00714.99
7.2.220.0090.00315.08
7.2.210.0120.00215.26
7.2.200.0050.01114.94
7.2.190.0080.00715.16
7.2.180.0050.01015.17
7.2.170.0030.01215.07
7.2.160.0030.00915.06
7.2.150.0060.01016.57
7.2.140.0040.01116.89
7.2.130.0040.00916.79
7.2.120.0080.00716.92
7.2.110.0060.00916.88
7.2.100.0080.00816.72
7.2.90.0040.01117.13
7.2.80.0070.00616.96
7.2.70.0100.00317.07
7.2.60.0060.00816.82
7.2.50.0050.00916.88
7.2.40.0050.00817.00
7.2.30.0060.01017.00
7.2.20.0020.01116.79
7.2.10.0080.00516.89
7.2.00.0060.00717.76
7.1.330.0080.00815.74
7.1.320.0030.01215.86
7.1.310.0020.01115.79
7.1.300.0030.00915.71
7.1.290.0020.01315.73
7.1.280.0050.00615.87
7.1.270.0040.00715.84
7.1.260.0040.00915.88
7.1.250.0060.00615.72
7.1.240.0060.00715.75
7.1.230.0040.00915.74
7.1.220.0030.00915.77
7.1.210.0070.00915.62
7.1.200.0030.01015.83
7.1.190.0040.01015.75
7.1.180.0030.01215.92
7.1.170.0080.00815.88
7.1.160.0070.00515.68
7.1.150.0110.00315.64
7.1.140.0050.01015.66
7.1.130.0030.00815.77
7.1.120.0080.00515.78
7.1.110.0060.00515.96
7.1.100.0060.00616.56
7.1.90.0050.00615.74
7.1.80.0020.01015.84
7.1.70.0050.00616.02
7.1.60.0070.00916.91
7.1.50.0100.00822.08
7.1.40.0030.00915.64
7.1.30.0090.00515.77
7.1.20.0080.00715.85
7.1.10.0050.01015.85
7.1.00.0070.02817.92
7.0.330.0040.01015.27
7.0.320.0020.01115.24
7.0.310.0050.01015.32
7.0.300.0080.00915.42
7.0.290.0040.00915.41
7.0.280.0050.00415.29
7.0.270.0070.00415.43
7.0.260.0010.00915.36
7.0.250.0020.01115.49
7.0.240.0060.00815.30
7.0.230.0050.00615.46
7.0.220.0060.00715.46
7.0.210.0030.00915.22
7.0.200.0080.00715.20
7.0.190.0090.00515.37
7.0.180.0060.00515.39
7.0.170.0060.00615.34
7.0.160.0080.00615.27
7.0.150.0030.00915.27
7.0.140.0090.02417.63
7.0.130.0040.01115.24
7.0.120.0020.01315.37
7.0.110.0080.00515.36
7.0.100.0060.00515.49
7.0.90.0050.00615.47
7.0.80.0040.00915.37
7.0.70.0030.01015.36
7.0.60.0040.02916.93
7.0.50.0040.03016.20
7.0.40.0090.01915.63
7.0.30.0120.01515.62
7.0.20.0170.03015.73
7.0.10.0060.03315.73
7.0.00.0060.03715.62
5.6.400.0000.01314.40
5.6.390.0090.00914.46
5.6.380.0090.00714.40
5.6.370.0040.00714.57
5.6.360.0060.00614.64
5.6.350.0020.01014.35
5.6.340.0050.01014.43
5.6.330.0090.00514.38
5.6.320.0060.00614.70
5.6.310.0050.00513.98
5.6.300.0060.00714.54
5.6.290.0050.00614.24
5.6.280.0070.02716.67
5.6.270.0030.00914.47
5.6.260.0100.00714.38
5.6.250.0100.00314.44
5.6.240.0050.00514.57
5.6.230.0090.00214.43
5.6.220.0110.00514.32
5.6.210.0030.03616.38
5.6.200.0070.03015.68
5.6.190.0040.01916.46
5.6.180.0140.03216.37
5.6.170.0210.02616.49
5.6.160.0120.03116.45
5.6.150.0070.01415.64
5.6.140.0060.03215.64
5.6.130.0070.03315.66
5.6.120.0050.03516.59
5.6.110.0070.01816.67
5.6.100.0040.02216.79
5.6.90.0060.02416.60
5.6.80.0030.03016.36
5.6.70.1080.01716.30
5.6.60.0050.01014.13
5.6.50.0050.00714.42
5.6.40.0050.01214.17
5.6.30.0030.01214.21
5.6.20.0120.00514.41
5.6.10.0090.00614.51
5.6.00.0040.01214.41
5.5.380.0080.00312.79
5.5.370.0000.01112.90
5.5.360.0050.00513.08
5.5.350.0070.02515.37
5.5.340.0030.03314.63
5.5.330.0070.01715.40
5.5.320.0210.03115.36
5.5.310.0150.02115.34
5.5.300.0050.02014.66
5.5.290.0040.02414.69
5.5.280.0070.03215.72
5.5.270.0030.03115.40
5.5.260.0040.01715.42
5.5.250.0080.03115.31
5.5.240.0080.02915.11
5.5.230.0070.00712.77
5.5.220.0020.00712.89
5.5.210.0080.00312.71
5.5.200.0000.01312.96
5.5.190.0110.00512.59
5.5.180.0030.00912.77
5.5.170.0020.01212.57
5.5.160.0030.00713.03
5.5.150.0000.01012.71
5.5.140.0020.01412.83
5.5.130.0030.00812.80
5.5.120.0040.00712.90
5.5.110.0000.01312.81
5.5.100.0080.00412.66
5.5.90.0040.01112.81
5.5.80.0020.01012.76
5.5.70.0040.00712.71
5.5.60.0020.00812.98
5.5.50.0060.00512.72
5.5.40.0050.00712.91
5.5.30.0090.00212.71
5.5.20.0030.00812.88
5.5.10.0060.00612.92
5.5.00.0040.00912.85
5.4.450.0070.02413.76
5.4.440.0310.02413.84
5.4.430.0290.02413.84
5.4.420.0320.02414.16
5.4.410.0220.02114.07
5.4.400.0270.02913.86
5.4.390.0270.02813.94
5.4.380.0080.02813.73
5.4.370.0110.02613.69
5.4.360.0130.02113.65
5.4.350.0150.02013.64
5.4.340.0090.02313.56
5.4.330.0040.00611.07
5.4.320.0070.01511.59
5.4.310.0040.01711.59
5.4.300.0060.01911.54
5.4.290.0050.01811.61
5.4.280.0040.01711.54
5.4.270.0040.01911.44
5.4.260.0040.02011.49
5.4.250.0090.02611.58
5.4.240.0080.02011.60
5.4.230.0070.02111.55
5.4.220.0050.02411.60
5.4.210.0080.01911.44
5.4.200.0040.02011.56
5.4.190.0070.01911.55
5.4.180.0070.01911.62
5.4.170.0070.01711.61
5.4.160.0080.01811.47
5.4.150.0050.02311.63
5.4.140.0060.03311.48
5.4.130.0050.02411.48
5.4.120.0060.02111.49
5.4.110.0060.02411.40
5.4.100.0050.01811.43
5.4.90.0040.01811.43
5.4.80.0050.01911.50
5.4.70.0050.02111.58
5.4.60.0100.01511.43
5.4.50.0080.01911.38
5.4.40.0090.02611.42
5.4.30.0050.02011.38
5.4.20.0060.01711.54
5.4.10.0030.01911.36
5.4.00.0040.01611.27
5.3.290.0040.02011.12
5.3.280.0040.01710.92
5.3.270.0040.01910.92
5.3.260.0070.01811.09
5.3.250.0060.02511.05
5.3.240.0070.01910.92
5.3.230.0070.01810.96
5.3.220.0040.01910.86
5.3.210.0040.02110.96
5.3.200.0050.01810.98
5.3.190.0040.01810.97
5.3.180.0080.03311.02
5.3.170.0090.02511.02
5.3.160.0070.02311.06
5.3.150.0050.02311.09
5.3.140.0040.02511.04
5.3.130.0050.02611.06
5.3.120.0120.03210.99
5.3.110.0080.02410.92
5.3.100.0060.02110.89
5.3.90.0060.02210.85
5.3.80.0060.02410.83
5.3.70.0140.03310.75
5.3.60.0060.01910.80
5.3.50.0090.02010.70
5.3.40.0210.04310.75
5.3.30.0080.02510.74
5.3.20.0070.01610.67
5.3.10.0080.01410.51
5.3.00.0040.02010.51
5.2.170.0040.0259.55
5.2.160.0080.0189.55
5.2.150.0070.0219.56
5.2.140.0110.0609.55
5.2.130.0050.0249.54
5.2.120.0070.0229.53
5.2.110.0070.0159.54
5.2.100.0100.0269.54
5.2.90.0030.0239.53
5.2.80.0040.0219.54
5.2.70.0060.0279.53
5.2.60.0040.0189.51
5.2.50.0060.0209.50
5.2.40.0090.0229.48
5.2.30.0060.0239.47
5.2.20.0040.0249.46
5.2.10.0050.0379.43
5.2.00.0070.0269.36
5.1.60.0040.0219.00
5.1.50.0050.0149.00
5.1.40.0060.0168.99
5.1.30.0060.0209.17
5.1.20.0040.0219.18
5.1.10.0060.0279.04
5.1.00.0080.0259.04
5.0.50.0050.0148.28
5.0.40.0060.0118.21
5.0.30.0040.0228.11
5.0.20.0070.0188.10
5.0.10.0040.0158.09
5.0.00.0020.0278.09
4.4.90.0070.0217.37
4.4.80.0070.0147.36
4.4.70.0030.0127.36
4.4.60.0050.0147.36
4.4.50.0060.0187.36
4.4.40.0050.0157.33
4.4.30.0030.0097.36
4.4.20.0040.0107.40
4.4.10.0040.0107.40
4.4.00.0020.0167.36
4.3.110.0030.0097.31
4.3.100.0010.0127.31
4.3.90.0010.0127.29
4.3.80.0020.0167.27
4.3.70.0020.0107.29
4.3.60.0030.0097.29
4.3.50.0030.0117.29
4.3.40.0050.0187.25
4.3.30.0030.0226.61
4.3.20.0040.0236.60
4.3.10.0080.0356.59
4.3.00.0000.01410.16

preferences:
48.87 ms | 401 KiB | 5 Q