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[$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 = $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.0100.00718.56
8.3.50.0120.00921.99
8.3.40.0120.00318.70
8.3.30.0110.00418.89
8.3.20.0080.00018.82
8.3.10.0080.00020.61
8.3.00.0050.00323.74
8.2.180.0040.01116.88
8.2.170.0160.00022.96
8.2.160.0130.00020.38
8.2.150.0030.00524.18
8.2.140.0030.00624.66
8.2.130.0060.00326.16
8.2.120.0080.00019.25
8.2.110.0100.00020.98
8.2.100.0080.00417.78
8.2.90.0050.00319.17
8.2.80.0000.00817.93
8.2.70.0040.00417.50
8.2.60.0040.00417.93
8.2.50.0040.00418.07
8.2.40.0040.00418.34
8.2.30.0000.00819.96
8.2.20.0000.00717.86
8.2.10.0040.00417.66
8.2.00.0040.00417.67
8.1.280.0090.00625.92
8.1.270.0090.00023.99
8.1.260.0120.00626.35
8.1.250.0050.00328.09
8.1.240.0070.00322.61
8.1.230.0070.00420.97
8.1.220.0000.00817.80
8.1.210.0050.00319.04
8.1.200.0060.00317.36
8.1.190.0000.00817.66
8.1.180.0050.00218.10
8.1.170.0030.00618.87
8.1.160.0000.00718.96
8.1.150.0040.00418.79
8.1.140.0040.00417.36
8.1.130.0030.00317.91
8.1.120.0040.00417.50
8.1.110.0040.00417.55
8.1.100.0050.00317.46
8.1.90.0040.00417.48
8.1.80.0040.00417.49
8.1.70.0030.00317.45
8.1.60.0030.00617.64
8.1.50.0080.00017.54
8.1.40.0030.00517.57
8.1.30.0050.00517.58
8.1.20.0000.00917.65
8.1.10.0030.00517.68
8.1.00.0060.00317.41
8.0.300.0130.00019.85
8.0.290.0030.00616.75
8.0.280.0030.00318.36
8.0.270.0000.00717.24
8.0.260.0040.00416.91
8.0.250.0040.00417.01
8.0.240.0050.00316.97
8.0.230.0000.00717.00
8.0.220.0040.00416.79
8.0.210.0040.00416.91
8.0.200.0040.00416.90
8.0.190.0040.00416.96
8.0.180.0040.00416.99
8.0.170.0040.00416.87
8.0.160.0040.00416.94
8.0.150.0060.00616.95
8.0.140.0060.00616.89
8.0.130.0030.00613.37
8.0.120.0040.00416.86
8.0.110.0000.00716.80
8.0.100.0000.00716.83
8.0.90.0040.00416.97
8.0.80.0100.01016.95
8.0.70.0050.00516.74
8.0.60.0040.00416.93
8.0.50.0000.00716.99
8.0.30.0090.01416.98
8.0.20.0140.00517.40
8.0.10.0040.00416.88
8.0.00.0110.01216.75
7.4.330.0060.00014.84
7.4.320.0030.00316.64
7.4.300.0000.00616.64
7.4.290.0000.00716.64
7.4.280.0070.00016.60
7.4.270.0030.00316.65
7.4.260.0030.00313.30
7.4.250.0030.00516.58
7.4.240.0000.00716.55
7.4.230.0050.00216.61
7.4.220.0100.00716.43
7.4.210.0070.01116.65
7.4.200.0000.00716.73
7.4.190.0000.00816.69
7.4.160.0100.00716.71
7.4.150.0130.00417.40
7.4.140.0090.01117.86
7.4.130.0070.01016.61
7.4.120.0130.00516.52
7.4.110.0060.01316.59
7.4.100.0030.01316.43
7.4.90.0170.00016.48
7.4.80.0130.00719.37
7.4.70.0070.01116.63
7.4.60.0160.00016.30
7.4.50.0090.00016.55
7.4.40.0070.01122.27
7.4.30.0090.01316.53
7.4.10.0070.01314.95
7.4.00.0060.01114.79
7.3.330.0050.00013.43
7.3.320.0070.00013.37
7.3.310.0070.00016.30
7.3.300.0000.00716.45
7.3.290.0080.00516.45
7.3.280.0060.01016.36
7.3.270.0070.01017.40
7.3.260.0100.01218.24
7.3.250.0090.00916.55
7.3.240.0190.00316.33
7.3.230.0070.01116.64
7.3.210.0140.00516.49
7.3.200.0130.00719.39
7.3.190.0120.00716.52
7.3.180.0070.01016.24
7.3.170.0130.00916.58
7.3.160.0000.01716.54
7.3.130.0060.00915.16
7.3.120.0080.00714.71
7.3.110.0070.01314.97
7.3.100.0000.01414.84
7.3.90.0060.01015.04
7.3.80.0070.00714.95
7.3.70.0040.01114.95
7.3.60.0030.01314.89
7.3.50.0030.01314.80
7.3.40.0030.01214.90
7.3.30.0030.01014.81
7.3.20.0100.00316.39
7.3.10.0200.00016.71
7.3.00.0100.01016.77
7.2.330.0070.01016.72
7.2.320.0060.01216.71
7.2.310.0070.01716.65
7.2.300.0070.01016.50
7.2.290.0100.00716.83
7.2.260.0100.01015.01
7.2.250.0030.01315.27
7.2.240.0070.00715.29
7.2.230.0070.01014.82
7.2.220.0030.01315.27
7.2.210.0090.00315.04
7.2.200.0000.01715.29
7.2.190.0090.00315.05
7.2.180.0040.00414.94
7.2.170.0060.00615.29
7.2.160.0070.00715.11
7.2.150.0090.00617.06
7.2.140.0040.01516.82
7.2.130.0120.00617.13
7.2.120.0130.00316.84
7.2.110.0000.01417.00
7.2.100.0110.00416.88
7.2.90.0070.01017.03
7.2.80.0000.01316.96
7.2.70.0120.00317.09
7.2.60.0070.01016.94
7.2.50.0150.00816.82
7.2.40.0090.00616.93
7.2.30.0000.01416.78
7.2.20.0040.01116.81
7.2.10.0070.00716.98
7.2.00.0030.01216.75
7.1.330.0030.01015.78
7.1.320.0040.01115.58
7.1.310.0060.00815.81
7.1.300.0030.01015.82
7.1.290.0110.00415.85
7.1.280.0040.01215.89
7.1.270.0110.00315.86
7.1.260.0070.01115.76
7.1.250.0060.00615.76
7.1.240.0060.00916.03
7.1.230.0090.00615.99
7.1.220.0040.01215.98
7.1.210.0030.01015.68
7.1.200.0080.00615.87
7.1.190.0080.00515.68
7.1.180.0000.00915.75
7.1.170.0040.00415.93
7.1.160.0030.00715.56
7.1.150.0030.00615.83
7.1.140.0040.00715.84
7.1.130.0120.00015.60
7.1.120.0030.01016.00
7.1.110.0110.00715.55
7.1.100.0040.00716.02
7.1.90.0040.01115.89
7.1.80.0100.00615.89
7.1.70.0050.00716.51
7.1.60.0040.01217.57
7.1.50.0090.00916.47
7.1.40.0060.00615.54
7.1.30.0080.00015.87
7.1.20.0040.00415.84
7.1.10.0030.01015.77
7.1.00.0000.04219.03
7.0.330.0030.01015.45
7.0.320.0100.00315.46
7.0.310.0070.00715.60
7.0.300.0030.01015.45
7.0.290.0040.00715.07
7.0.280.0070.00715.55
7.0.270.0060.00315.40
7.0.260.0150.00015.16
7.0.250.0040.01115.12
7.0.240.0030.00915.57
7.0.230.0030.01015.26
7.0.220.0030.01015.35
7.0.210.0070.00315.23
7.0.200.0030.00516.15
7.0.190.0030.00515.57
7.0.180.0110.00015.10
7.0.170.0070.00715.56
7.0.160.0060.00315.45
7.0.150.0090.00615.18
7.0.140.0050.03818.80
7.0.130.0000.00915.49
7.0.120.0030.00915.43
7.0.110.0050.00515.46
7.0.100.0080.00415.49
7.0.90.0040.01115.58
7.0.80.0000.00915.59
7.0.70.0060.00615.66
7.0.60.0030.04118.60
7.0.50.0020.04718.86
7.0.40.0050.03916.64
7.0.30.0030.04716.68
7.0.20.0070.04216.74
7.0.10.0020.04516.76
7.0.00.0020.04916.75
5.6.400.0070.01114.36
5.6.390.0030.01214.67
5.6.380.0040.00414.48
5.6.370.0030.01114.72
5.6.360.0030.01014.64
5.6.350.0000.01214.48
5.6.340.0090.00014.66
5.6.330.0000.01114.46
5.6.320.0090.00014.59
5.6.310.0030.01014.28
5.6.300.0110.00414.41
5.6.290.0030.01014.73
5.6.280.0110.00314.52
5.6.270.0000.01614.11
5.6.260.0030.00914.56
5.6.250.0090.00614.66
5.6.240.0000.01414.76
5.6.230.0130.00314.49
5.6.220.0060.00914.54
5.6.210.0070.03617.53
5.6.200.0050.04217.89
5.6.190.0050.04417.72
5.6.180.0100.02717.74
5.6.170.0000.04417.73
5.6.160.0050.04217.92
5.6.150.0030.03817.95
5.6.140.0030.04317.61
5.6.130.0120.03917.64
5.6.120.0050.03417.79
5.6.110.0030.04517.74
5.6.100.0060.04617.78
5.6.90.0050.04417.70
5.6.80.0020.02217.45
5.6.70.0070.03817.47
5.6.60.0080.04017.49
5.6.50.0110.04017.32
5.6.40.0060.03917.34
5.6.30.0050.04117.46
5.6.20.0070.04217.46
5.6.10.0000.04117.37
5.6.00.0070.03517.44
5.5.380.0030.01414.54
5.5.370.0120.00314.50
5.5.360.0100.00714.13
5.5.350.0070.03017.44
5.5.340.0010.03817.60
5.5.330.0090.04317.68
5.5.320.0060.03517.65
5.5.310.0080.03817.64
5.5.300.0100.04017.64
5.5.290.0020.04717.70
5.5.280.0070.04217.55
5.5.270.0060.04617.49
5.5.260.0070.04317.70
5.5.250.0080.04317.59
5.5.240.0050.03917.26
5.5.230.0060.03017.04
5.5.220.0060.04117.15
5.5.210.0030.04317.23
5.5.200.0000.04717.22
5.5.190.0080.03217.11
5.5.180.0080.04017.14
5.5.170.0030.01014.39
5.5.160.0130.03717.21
5.5.150.0090.02417.36
5.5.140.0120.04317.29
5.5.130.0100.02317.11
5.5.120.0080.02117.04
5.5.110.0090.02117.35
5.5.100.0130.02217.15
5.5.90.0080.02416.97
5.5.80.0090.02117.23
5.5.70.0090.02217.15
5.5.60.0100.02817.16
5.5.50.0050.02517.22
5.5.40.0080.02117.30
5.5.30.0060.02117.11
5.5.20.0080.02217.22
5.5.10.0040.02117.23
5.5.00.0070.01717.13
5.4.450.0060.04315.79
5.4.440.0050.04115.85
5.4.430.0050.04515.89
5.4.420.0040.03915.84
5.4.410.0070.03715.73
5.4.400.0050.02815.76
5.4.390.0030.04315.72
5.4.380.0030.04215.72
5.4.370.0040.03715.68
5.4.360.0070.03915.74
5.4.350.0030.04315.68
5.4.340.0040.04115.71
5.4.330.0080.00412.35
5.4.320.0050.04115.71
5.4.310.0030.03015.76
5.4.300.0150.01815.71
5.4.290.0100.02015.71
5.4.280.0100.02315.78
5.4.270.0110.02315.71
5.4.260.0030.02815.76
5.4.250.0120.01915.69
5.4.240.0100.02115.69
5.4.230.0070.02115.71
5.4.220.0080.02715.73
5.4.210.0050.02415.70
5.4.200.0100.01315.76
5.4.190.0010.02315.76
5.4.180.0050.01715.64
5.4.170.0000.02215.76
5.4.160.0090.01815.70
5.4.150.0070.01715.62
5.4.140.0100.01314.37
5.4.130.0050.01914.38
5.4.120.0060.01414.30
5.4.110.0050.01814.37
5.4.100.0060.01614.36
5.4.90.0050.01814.41
5.4.80.0030.01914.35
5.4.70.0060.01614.45
5.4.60.0060.01314.36
5.4.50.0020.02414.29
5.4.40.0040.01814.39
5.4.30.0000.02014.40
5.4.20.0020.02014.33
5.4.10.0030.01614.34
5.4.00.0040.01514.02
5.3.290.0070.03013.50
5.3.280.0060.02113.37
5.3.270.0020.02013.44
5.3.260.0050.02013.37
5.3.250.0050.01713.44
5.3.240.0050.01713.43
5.3.230.0060.01513.43
5.3.220.0070.01513.43
5.3.210.0020.01813.38
5.3.200.0040.01613.43
5.3.190.0070.01313.38
5.3.180.0070.01513.43
5.3.170.0080.01713.45
5.3.160.0010.02113.44
5.3.150.0030.02513.42
5.3.140.0030.02513.40
5.3.130.0030.02313.44
5.3.120.0020.03313.44
5.3.110.0020.01713.36
5.3.100.0020.01613.18
5.3.90.0030.04013.16
5.3.80.0020.01813.13
5.3.70.0030.03413.15
5.3.60.0020.02413.17
5.3.50.0060.02713.13
5.3.40.0020.03813.11
5.3.30.0050.03813.12
5.3.20.0050.03312.99
5.3.10.0040.03012.88
5.3.00.0000.04012.96
5.2.170.0030.03010.99
5.2.160.0030.03311.05
5.2.150.0070.06310.93
5.2.140.0000.06311.08
5.2.130.0030.04711.02
5.2.120.0030.04711.08
5.2.110.0000.05311.11
5.2.100.0030.06011.14
5.2.90.0030.05311.11
5.2.80.0030.04311.08
5.2.70.0000.07011.09
5.2.60.0030.05711.06
5.2.50.0130.05310.85
5.2.40.0030.05311.02
5.2.30.0000.06710.76
5.2.20.0030.06010.96
5.2.10.0100.04710.86
5.2.00.0000.06310.57
5.1.60.0070.04310.02
5.1.50.0030.0509.98
5.1.40.0030.0509.96
5.1.30.0070.05310.35
5.1.20.0100.03310.21
5.1.10.0070.05310.11
5.1.00.0000.05310.02
5.0.50.0000.0378.82
5.0.40.0030.0438.82
5.0.30.0000.0538.82
5.0.20.0000.0408.82
5.0.10.0030.0338.82
5.0.00.0030.0578.82
4.4.90.0000.0378.82
4.4.80.0030.0338.82
4.4.70.0000.0378.82
4.4.60.0000.0308.82
4.4.50.0000.0378.82
4.4.40.0000.0538.82
4.4.30.0000.0378.82
4.4.20.0000.0338.82
4.4.10.0000.0378.82
4.4.00.0030.0478.82
4.3.110.0070.0278.82
4.3.100.0030.0338.82
4.3.90.0070.0308.82
4.3.80.0070.0478.82
4.3.70.0070.0278.82
4.3.60.0000.0378.82
4.3.50.0000.0378.82
4.3.40.0000.0578.82
4.3.30.0030.0378.82
4.3.20.0030.0338.82
4.3.10.0000.0338.82
4.3.00.0030.0238.82

preferences:
42.96 ms | 401 KiB | 5 Q