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', 4, 8.3, 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 = 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.40.0100.01018.79
8.3.30.0090.00618.76
8.3.20.0040.00418.85
8.3.10.0080.00020.46
8.3.00.0080.00023.73
8.2.170.0090.00622.96
8.2.160.0070.00720.43
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00319.49
8.2.110.0030.00620.47
8.2.100.0090.00317.84
8.2.90.0080.00019.34
8.2.80.0000.00818.18
8.2.70.0000.00817.63
8.2.60.0000.00818.05
8.2.50.0030.00918.07
8.2.40.0030.00518.34
8.2.30.0000.00819.97
8.2.20.0040.00417.70
8.2.10.0000.00819.54
8.2.00.0030.00717.89
8.1.270.0000.00723.99
8.1.260.0070.01126.35
8.1.250.0050.00328.09
8.1.240.0120.00922.71
8.1.230.0090.00321.09
8.1.220.0080.00018.77
8.1.210.0050.00318.97
8.1.200.0060.00317.47
8.1.190.0060.00317.43
8.1.180.0000.00818.10
8.1.170.0040.00418.59
8.1.160.0040.00418.99
8.1.150.0050.00318.70
8.1.140.0050.00317.55
8.1.130.0000.00717.97
8.1.120.0070.00017.59
8.1.110.0040.00417.55
8.1.100.0040.00417.50
8.1.90.0000.00717.59
8.1.80.0050.00217.48
8.1.70.0000.00717.46
8.1.60.0030.00717.63
8.1.50.0000.00817.54
8.1.40.0080.00017.57
8.1.30.0000.00817.70
8.1.20.0040.00417.77
8.1.10.0000.00817.57
8.1.00.0000.00817.62
8.0.300.0090.00020.10
8.0.290.0070.00017.41
8.0.280.0050.00318.58
8.0.270.0030.00317.32
8.0.260.0000.00716.91
8.0.250.0070.00017.09
8.0.240.0030.00617.05
8.0.230.0070.00017.06
8.0.220.0030.00416.90
8.0.210.0050.00316.97
8.0.200.0000.00717.04
8.0.190.0000.00717.04
8.0.180.0070.00016.90
8.0.170.0040.00416.89
8.0.160.0040.00416.92
8.0.150.0040.00416.95
8.0.140.0040.00416.94
8.0.130.0060.00013.40
8.0.120.0030.00516.94
8.0.110.0040.00416.94
8.0.100.0040.00417.04
8.0.90.0080.00017.03
8.0.80.0120.00316.88
8.0.70.0060.00316.80
8.0.60.0040.00416.89
8.0.50.0000.00716.86
8.0.30.0140.00617.17
8.0.20.0070.01317.40
8.0.10.0050.00317.09
8.0.00.0080.01116.76
7.4.330.0030.00313.43
7.4.320.0060.00016.75
7.4.300.0000.00616.55
7.4.290.0000.00716.59
7.4.280.0100.00016.71
7.4.270.0030.00316.59
7.4.260.0050.00013.28
7.4.250.0050.00316.57
7.4.240.0040.00416.75
7.4.230.0070.00016.79
7.4.220.0160.00616.76
7.4.210.0080.00816.65
7.4.200.0000.00716.71
7.4.190.0040.00316.67
7.4.160.0090.00616.61
7.4.150.0030.01617.40
7.4.140.0090.00917.86
7.4.130.0160.00516.62
7.4.120.0080.01416.65
7.4.110.0060.01216.57
7.4.100.0100.00716.54
7.4.90.0140.00416.51
7.4.80.0110.00619.37
7.4.70.0130.00416.62
7.4.60.0120.00916.61
7.4.50.0060.00316.53
7.4.40.0070.00722.27
7.4.30.0060.01116.46
7.4.10.0030.01415.18
7.4.00.0130.00314.85
7.3.330.0000.00513.43
7.3.320.0020.00213.46
7.3.310.0030.00316.36
7.3.300.0000.00716.48
7.3.290.0140.00316.52
7.3.280.0080.00916.45
7.3.270.0050.01217.40
7.3.260.0130.00718.24
7.3.250.0130.00816.55
7.3.240.0110.00716.48
7.3.230.0110.01016.45
7.3.210.0100.01016.71
7.3.200.0090.01219.39
7.3.190.0100.01316.56
7.3.180.0130.01016.59
7.3.170.0090.01216.64
7.3.160.0060.01016.76
7.3.130.0150.00014.86
7.3.120.0080.00814.94
7.3.110.0050.01215.02
7.3.100.0050.01214.98
7.3.90.0100.00214.88
7.3.80.0070.01015.00
7.3.70.0060.00814.97
7.3.60.0010.01114.78
7.3.50.0050.00914.79
7.3.40.0080.00614.66
7.3.30.0030.01114.99
7.3.20.0070.00716.74
7.3.10.0080.00816.68
7.3.00.0090.00616.64
7.2.330.0130.00416.73
7.2.320.0070.01016.96
7.2.310.0140.00816.94
7.2.300.0040.01516.88
7.2.290.0120.00716.92
7.2.260.0070.01115.11
7.2.250.0050.01014.95
7.2.240.0070.01015.16
7.2.230.0100.00715.10
7.2.220.0040.00914.97
7.2.210.0060.00915.04
7.2.200.0050.00615.23
7.2.190.0050.01215.03
7.2.180.0050.01015.00
7.2.170.0030.01115.05
7.2.160.0070.00314.98
7.2.150.0070.01016.91
7.2.140.0120.00316.91
7.2.130.0060.00616.71
7.2.120.0050.00716.78
7.2.110.0090.00816.83
7.2.100.0030.00916.87
7.2.90.0070.00616.95
7.2.80.0050.01116.98
7.2.70.0070.00816.93
7.2.60.0030.01016.76
7.2.50.0090.00716.86
7.2.40.0060.01017.03
7.2.30.0050.00517.02
7.2.20.0080.00616.90
7.2.10.0030.00716.93
7.2.00.0080.00417.65
7.1.330.0080.00716.02
7.1.320.0090.00515.81
7.1.310.0020.01215.87
7.1.300.0040.00915.80
7.1.290.0030.01215.85
7.1.280.0080.00515.73
7.1.270.0040.00815.80
7.1.260.0020.01015.92
7.1.250.0070.00415.72
7.1.240.0000.01315.89
7.1.230.0070.01016.05
7.1.220.0060.00915.73
7.1.210.0030.00915.79
7.1.200.0030.01315.69
7.1.190.0060.00615.82
7.1.180.0060.00615.66
7.1.170.0000.01115.98
7.1.160.0050.00515.96
7.1.150.0040.00815.59
7.1.140.0000.01315.79
7.1.130.0090.00615.76
7.1.120.0040.00815.85
7.1.110.0090.00315.72
7.1.100.0080.00417.13
7.1.90.0110.00415.82
7.1.80.0000.01315.76
7.1.70.0070.01016.45
7.1.60.0040.01617.66
7.1.50.0070.01216.46
7.1.40.0030.00615.64
7.1.30.0040.01115.68
7.1.20.0070.01015.75
7.1.10.0070.00715.91
7.1.00.0030.02819.08
7.0.330.0040.00815.43
7.0.320.0100.00715.59
7.0.310.0030.01215.56
7.0.300.0030.01415.64
7.0.290.0070.00715.46
7.0.280.0030.00615.35
7.0.270.0000.01315.27
7.0.260.0080.00015.17
7.0.250.0070.00615.50
7.0.240.0040.00715.26
7.0.230.0030.01015.46
7.0.220.0090.00615.32
7.0.210.0060.00915.58
7.0.200.0050.00616.14
7.0.190.0090.00615.24
7.0.180.0110.00315.51
7.0.170.0040.01115.59
7.0.160.0030.00615.41
7.0.150.0030.01415.22
7.0.140.0080.03318.53
7.0.130.0040.00415.21
7.0.120.0060.00315.35
7.0.110.0030.01015.34
7.0.100.0030.00615.27
7.0.90.0100.00015.20
7.0.80.0050.00515.48
7.0.70.0030.00915.21
7.0.60.0080.03017.81
7.0.50.0050.03116.71
7.0.40.0070.04616.80
7.0.30.0050.02716.88
7.0.20.0170.03116.92
7.0.10.0020.04016.82
7.0.00.0080.04516.86
5.6.400.0030.00614.71
5.6.390.0070.01014.48
5.6.380.0040.00814.42
5.6.370.0060.00314.42
5.6.360.0070.01014.68
5.6.350.0000.01714.25
5.6.340.0110.00414.40
5.6.330.0060.00314.78
5.6.320.0040.00814.36
5.6.310.0070.00314.74
5.6.300.0060.00614.18
5.6.290.0040.00814.71
5.6.280.0090.04617.78
5.6.270.0040.01114.20
5.6.260.0060.00914.57
5.6.250.0030.00714.50
5.6.240.0080.00414.70
5.6.230.0080.00814.66
5.6.220.0050.00514.25
5.6.210.0050.02717.47
5.6.200.0080.02816.39
5.6.190.0110.04617.49
5.6.180.0170.04317.46
5.6.170.0150.03817.27
5.6.160.0030.02617.51
5.6.150.0060.02216.28
5.6.140.0100.04316.42
5.6.130.0020.02716.55
5.6.120.0060.03117.78
5.6.110.0050.04517.88
5.6.100.0070.03717.76
5.6.90.0070.03817.83
5.6.80.0030.02317.31
5.6.70.0070.00714.16
5.6.60.0000.01114.63
5.6.50.0060.00314.39
5.6.40.0060.00614.43
5.6.30.0060.00914.34
5.6.20.0000.01514.41
5.6.10.0030.01214.33
5.6.00.0100.00314.59
5.5.380.0110.00314.46
5.5.370.0030.01014.46
5.5.360.0070.01014.46
5.5.350.1350.02017.26
5.5.340.0030.04516.16
5.5.330.0130.02517.28
5.5.320.0180.04317.05
5.5.310.0180.03717.47
5.5.300.0060.04316.30
5.5.290.0050.03116.24
5.5.280.0120.03617.65
5.5.270.0070.04217.57
5.5.260.0050.03017.60
5.5.250.0060.04917.43
5.5.240.0170.03917.12
5.5.230.0060.00914.48
5.5.220.0090.00614.30
5.5.210.0060.00614.48
5.5.200.0040.01214.38
5.5.190.0000.01014.59
5.5.180.0000.01414.07
5.5.170.0070.00714.39
5.5.160.0000.00914.22
5.5.150.0080.00814.30
5.5.140.0070.00714.35
5.5.130.0060.00614.43
5.5.120.0040.01214.32
5.5.110.0100.00314.32
5.5.100.0060.00914.13
5.5.90.0060.00914.30
5.5.80.0090.00614.29
5.5.70.0120.00314.31
5.5.60.0030.01014.15
5.5.50.0030.01014.52
5.5.40.0040.00814.61
5.5.30.0060.00914.05
5.5.20.0040.00813.99
5.5.10.0030.01314.05
5.5.00.0070.00714.51
5.4.450.0130.02215.44
5.4.440.0200.01615.56
5.4.430.0120.04215.55
5.4.420.0130.03815.50
5.4.410.0120.02715.41
5.4.400.0130.04015.28
5.4.390.0150.04015.22
5.4.380.0130.03615.31
5.4.370.0170.02015.20
5.4.360.0160.03815.27
5.4.350.0130.02815.40
5.4.340.0120.03715.40
5.4.330.0040.00711.56
5.4.320.0110.02315.20
5.4.310.0120.02415.39
5.4.300.0120.02215.40
5.4.290.0100.02315.33
5.4.280.0100.03815.20
5.4.270.0150.03815.31
5.4.260.0100.03115.32
5.4.250.0150.03015.30
5.4.240.0130.02915.34
5.4.230.0080.04315.25
5.4.220.0120.03015.32
5.4.210.0130.03615.39
5.4.200.0110.03015.42
5.4.190.0220.03215.30
5.4.180.0170.02315.39
5.4.170.0100.02915.34
5.4.160.0110.04115.40
5.4.150.0130.03715.24
5.4.140.0120.02514.12
5.4.130.0150.02014.06
5.4.120.0130.02813.95
5.4.110.0130.04014.10
5.4.100.0160.03414.08
5.4.90.0100.04214.07
5.4.80.0120.02513.92
5.4.70.0110.02813.91
5.4.60.0150.03714.05
5.4.50.0120.03014.04
5.4.40.0130.03313.99
5.4.30.0200.03013.99
5.4.20.0150.03213.94
5.4.10.0150.03514.00
5.4.00.0120.02213.91
5.3.290.0120.02413.91
5.3.280.0150.03813.91
5.3.270.0160.02913.91
5.3.260.0130.03813.91
5.3.250.0130.03913.91
5.3.240.0210.03313.91
5.3.230.0120.03813.91
5.3.220.0140.02513.91
5.3.210.0130.02313.91
5.3.200.0070.02513.91
5.3.190.0130.02013.91
5.3.180.0130.02013.91
5.3.170.0140.02913.91
5.3.160.0110.02013.91
5.3.150.0120.02913.91
5.3.140.0190.03713.91
5.3.130.0180.03313.91
5.3.120.0080.03113.91
5.3.110.0130.02013.91
5.3.100.0050.02513.91
5.3.90.0120.04013.91
5.3.80.0150.03013.91
5.3.70.0100.02413.91
5.3.60.0100.04113.91
5.3.50.0150.02313.91
5.3.40.0170.01513.91
5.3.30.0080.02113.91
5.3.20.0120.01713.91
5.3.10.0130.03913.91
5.3.00.0100.03413.91
5.2.170.0200.02716.25
5.2.160.0130.04316.25
5.2.150.0170.06716.25
5.2.140.0170.06016.25
5.2.130.0230.05316.25
5.2.120.0230.04016.25
5.2.110.0230.05716.25
5.2.100.0200.06016.25
5.2.90.0200.02316.25
5.2.80.0200.03016.25
5.2.70.0200.05716.25
5.2.60.0200.04716.25
5.2.50.0100.06016.25
5.2.40.0130.06316.25
5.2.30.0230.04716.25
5.2.20.0130.06016.25
5.2.10.0130.03716.25
5.2.00.0230.04316.25
5.1.60.0230.04316.25
5.1.50.0100.06316.25
5.1.40.0170.03016.25
5.1.30.0170.03016.25
5.1.20.0170.05016.25
5.1.10.0130.05016.25
5.1.00.0130.05716.25
5.0.50.0030.03016.25
5.0.40.0130.02316.25
5.0.30.0130.06016.25
5.0.20.0030.04316.25
5.0.10.0170.03316.25
5.0.00.0100.06016.25
4.4.90.0070.03316.25
4.4.80.0130.03316.25
4.4.70.0070.03316.25
4.4.60.0100.02316.25
4.4.50.0070.03716.25
4.4.40.0170.04016.25
4.4.30.0070.03016.25
4.4.20.0130.02716.25
4.4.10.0070.02716.25
4.4.00.0100.02716.25
4.3.110.0100.03316.25
4.3.100.0030.02716.25
4.3.90.0100.03316.25
4.3.80.0130.02316.25
4.3.70.0070.02016.25
4.3.60.0100.02716.25
4.3.50.0100.02016.25
4.3.40.0100.02716.25
4.3.30.0070.01716.25
4.3.20.0000.02316.25
4.3.10.0030.02016.25
4.3.00.0030.01316.25

preferences:
43.57 ms | 400 KiB | 5 Q