3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Anika', 0, 8.0, 11728], ['Maroula', 0, 8.4, 13032], ['Paravos', 0, 8.5, 15638], ['Billis', 0, 8.5, 16289], ['Terinkas', 0, 8.1, 17918], ['Tias', 0, 8.6, 19222], ['Liristis', 0, 9.1, 20851], ['Irina', 0, 9.3, 21176], ]; $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.0150.00418.96
8.3.30.0150.00019.25
8.3.20.0080.00020.45
8.3.10.0030.00523.79
8.3.00.0040.00419.50
8.2.170.0130.00322.96
8.2.160.0070.00720.53
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0040.00422.43
8.2.110.0030.00622.38
8.2.100.0040.00817.88
8.2.90.0080.00019.39
8.2.80.0040.00417.97
8.2.70.0030.00617.75
8.2.60.0040.00418.13
8.2.50.0030.00618.07
8.2.40.0080.00018.16
8.2.30.0000.00818.25
8.2.20.0000.00717.89
8.2.10.0070.00018.36
8.2.00.0070.00318.02
8.1.270.0060.00322.19
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0090.00023.98
8.1.230.0120.00019.21
8.1.220.0050.00317.78
8.1.210.0000.00918.77
8.1.200.0060.00317.34
8.1.190.0030.00617.63
8.1.180.0050.00318.10
8.1.170.0000.00818.78
8.1.160.0040.00422.12
8.1.150.0070.00018.66
8.1.140.0040.00417.48
8.1.130.0030.00317.94
8.1.120.0000.00717.55
8.1.110.0000.00717.59
8.1.100.0050.00317.61
8.1.90.0040.00417.46
8.1.80.0000.00717.45
8.1.70.0000.00717.43
8.1.60.0030.00617.69
8.1.50.0050.00317.51
8.1.40.0000.01017.62
8.1.30.0040.00417.76
8.1.20.0040.00417.76
8.1.10.0050.00517.58
8.1.00.0030.00517.54
8.0.300.0050.00318.77
8.0.290.0000.00817.18
8.0.280.0030.00518.52
8.0.270.0000.00717.36
8.0.260.0030.00317.41
8.0.250.0000.00717.05
8.0.240.0030.00317.03
8.0.230.0030.00317.05
8.0.220.0030.00316.87
8.0.210.0050.00516.89
8.0.200.0030.00316.95
8.0.190.0000.00717.07
8.0.180.0050.00317.03
8.0.170.0030.00616.95
8.0.160.0000.00716.95
8.0.150.0030.00416.96
8.0.140.0070.00017.00
8.0.130.0060.00013.44
8.0.120.0030.00516.91
8.0.110.0070.00016.96
8.0.100.0000.00716.94
8.0.90.0040.00416.96
8.0.80.0070.01116.95
8.0.70.0040.00416.87
8.0.60.0000.00816.83
8.0.50.0000.00717.04
8.0.30.0110.00817.23
8.0.20.0170.00817.40
8.0.10.0040.00417.04
8.0.00.0040.01516.89
7.4.330.0030.00315.11
7.4.320.0040.00416.62
7.4.300.0030.00416.53
7.4.290.0000.00716.71
7.4.280.0060.00316.60
7.4.270.0040.00416.61
7.4.260.0040.00416.72
7.4.250.0040.00416.71
7.4.240.0040.00316.63
7.4.230.0000.00816.80
7.4.220.0110.00716.48
7.4.210.0060.01016.59
7.4.200.0050.00316.81
7.4.190.0040.00416.61
7.4.160.0130.00516.66
7.4.150.0120.00617.40
7.4.140.0110.00817.86
7.4.130.0120.00716.62
7.4.120.0150.00616.51
7.4.110.0180.00016.58
7.4.100.0190.00016.58
7.4.90.0080.00916.52
7.4.80.0120.00919.39
7.4.70.0070.01116.55
7.4.60.0100.00716.52
7.4.50.0040.00416.70
7.4.40.0000.01822.77
7.4.30.0090.00916.75
7.4.10.0050.01515.16
7.4.00.0090.00814.87
7.3.330.0000.00613.25
7.3.320.0030.00313.32
7.3.310.0070.00016.50
7.3.300.0040.00416.47
7.3.290.0090.01216.43
7.3.280.0050.01216.48
7.3.270.0050.01417.40
7.3.260.0060.01016.53
7.3.250.0090.00916.57
7.3.240.0080.01116.48
7.3.230.0110.00716.65
7.3.210.0100.01016.80
7.3.200.0070.01119.39
7.3.190.0120.01216.35
7.3.180.0060.01016.67
7.3.170.0160.00016.54
7.3.160.0090.00916.77
7.3.130.0080.01114.70
7.3.120.0050.01214.94
7.3.110.0060.01114.93
7.3.100.0050.01014.88
7.3.90.0060.00814.88
7.3.80.0090.00714.96
7.3.70.0060.00614.93
7.3.60.0080.00814.82
7.3.50.0070.00514.89
7.3.40.0040.00814.81
7.3.30.0060.00614.70
7.3.20.0060.00816.64
7.3.10.0040.01016.67
7.3.00.0080.00516.80
7.2.330.0070.01116.70
7.2.320.0140.01016.58
7.2.310.0140.00316.95
7.2.300.0030.01516.64
7.2.290.0090.00916.95
7.2.260.0020.01515.17
7.2.250.0040.01415.15
7.2.240.0060.00915.03
7.2.230.0080.00715.17
7.2.220.0050.00915.09
7.2.210.0080.00615.27
7.2.200.0100.00615.15
7.2.190.0020.01115.07
7.2.180.0060.00715.19
7.2.170.0040.01015.10
7.2.160.0060.00615.02
7.2.150.0050.01116.88
7.2.140.0090.00216.88
7.2.130.0050.01417.00
7.2.120.0000.01316.87
7.2.110.0030.01216.88
7.2.100.0020.01416.90
7.2.90.0070.00716.80
7.2.80.0000.01016.95
7.2.70.0040.00917.00
7.2.60.0080.00617.04
7.2.50.0120.00517.04
7.2.40.0060.00816.72
7.2.30.0070.00816.90
7.2.20.0050.00817.03
7.2.10.0000.01316.90
7.2.00.0030.01017.74
7.1.330.0060.00815.82
7.1.320.0080.00415.73
7.1.310.0080.00615.86
7.1.300.0060.00715.69
7.1.290.0060.00715.80
7.1.280.0040.00815.86
7.1.270.0030.01015.87
7.1.260.0050.00615.89
7.1.250.0050.00815.74
7.1.240.0050.00815.85
7.1.230.0060.00915.83
7.1.220.0080.00715.99
7.1.210.0080.00815.90
7.1.200.0090.00415.80
7.1.190.0060.00615.77
7.1.180.0080.00415.85
7.1.170.0110.00315.88
7.1.160.0090.00315.70
7.1.150.0060.00815.70
7.1.140.0080.00615.94
7.1.130.0030.01115.92
7.1.120.0040.00815.68
7.1.110.0070.00815.90
7.1.100.0050.00616.40
7.1.90.0030.01015.71
7.1.80.0000.01115.78
7.1.70.0080.00416.28
7.1.60.0040.01017.08
7.1.50.0130.00416.35
7.1.40.0050.01015.89
7.1.30.0050.00715.94
7.1.20.0040.00915.75
7.1.10.0080.00315.74
7.1.00.0080.02917.92
7.0.330.0070.00715.43
7.0.320.0070.00815.45
7.0.310.0060.00615.41
7.0.300.0060.00615.51
7.0.290.0070.00415.45
7.0.280.0030.00915.24
7.0.270.0030.01015.28
7.0.260.0060.00815.39
7.0.250.0080.00615.34
7.0.240.0000.01115.54
7.0.230.0060.00515.53
7.0.220.0050.00815.55
7.0.210.0040.00615.39
7.0.200.0150.00715.28
7.0.190.0080.00315.45
7.0.180.0070.00415.46
7.0.170.0070.00815.24
7.0.160.0060.00515.45
7.0.150.0050.00715.45
7.0.140.0020.03217.65
7.0.130.0040.01115.52
7.0.120.0030.00815.52
7.0.110.0090.00315.42
7.0.100.0060.00315.45
7.0.90.0030.01015.21
7.0.80.0030.01315.24
7.0.70.0040.00815.57
7.0.60.0060.01917.04
7.0.50.0040.01916.26
7.0.40.0080.02115.69
7.0.30.0090.02015.68
7.0.20.0110.01715.76
7.0.10.0030.03415.72
7.0.00.0110.02515.54
5.6.400.0060.00514.32
5.6.390.0050.00814.29
5.6.380.0030.00914.70
5.6.370.0140.00214.50
5.6.360.0090.00514.62
5.6.350.0080.00514.23
5.6.340.0110.00314.40
5.6.330.0030.01014.62
5.6.320.0080.00814.54
5.6.310.0050.00814.57
5.6.300.0080.00614.50
5.6.290.0070.00514.67
5.6.280.0020.02916.67
5.6.270.0030.01014.31
5.6.260.0020.01114.75
5.6.250.0050.00814.39
5.6.240.0050.00814.40
5.6.230.0060.00914.43
5.6.220.0070.00814.40
5.6.210.0080.03216.55
5.6.200.0010.03915.74
5.6.190.0040.02116.48
5.6.180.0140.03016.50
5.6.170.0040.02416.47
5.6.160.0060.02316.50
5.6.150.0060.03215.75
5.6.140.0070.02715.76
5.6.130.0040.02015.80
5.6.120.0090.01716.71
5.6.110.0130.02516.60
5.6.100.0060.03316.65
5.6.90.0060.02216.63
5.6.80.0070.02616.56
5.6.70.0190.01916.30
5.6.60.0070.00814.43
5.6.50.0070.00714.40
5.6.40.0040.00714.52
5.6.30.0060.00614.50
5.6.20.0040.00914.44
5.6.10.0050.00814.39
5.6.00.0050.00614.38
5.5.380.0030.01114.43
5.5.370.0100.00714.45
5.5.360.0050.00714.38
5.5.350.0120.02416.46
5.5.340.0060.02115.59
5.5.330.0050.03116.41
5.5.320.0040.03316.44
5.5.310.0150.02816.49
5.5.300.0040.02715.52
5.5.290.0030.02015.65
5.5.280.0040.03416.55
5.5.270.0080.02916.49
5.5.260.0050.02816.42
5.5.250.0050.03116.35
5.5.240.0110.02816.32
5.5.230.0110.00514.40
5.5.220.0060.01114.34
5.5.210.0030.01014.47
5.5.200.0020.01214.10
5.5.190.0090.00314.57
5.5.180.0070.00514.31
5.5.170.0060.00814.54
5.5.160.0090.00414.38
5.5.150.0040.00914.34
5.5.140.0040.01014.40
5.5.130.0030.00914.38
5.5.120.0050.01014.35
5.5.110.0030.01114.29
5.5.100.0070.00614.34
5.5.90.0070.00514.49
5.5.80.0020.01014.33
5.5.70.0030.01014.46
5.5.60.0050.00914.23
5.5.50.0020.01114.62
5.5.40.0060.01014.31
5.5.30.0030.00714.35
5.5.20.0050.01014.37
5.5.10.0060.00414.40
5.5.00.0070.00514.30
5.4.450.0320.02214.21
5.4.440.0320.02114.21
5.4.430.0340.02514.17
5.4.420.0150.02314.17
5.4.410.0330.02914.22
5.4.400.0370.02114.23
5.4.390.0380.03214.09
5.4.380.0080.03013.91
5.4.370.0120.01914.04
5.4.360.0060.02613.96
5.4.350.0130.02614.03
5.4.340.0120.02213.98
5.4.330.0030.00611.72
5.4.320.0040.01612.00
5.4.310.0040.01812.00
5.4.300.0070.02211.96
5.4.290.0080.01711.91
5.4.280.0080.01711.93
5.4.270.0060.01411.91
5.4.260.0040.02211.89
5.4.250.0070.02111.88
5.4.240.0040.01811.85
5.4.230.0050.01811.88
5.4.220.0030.01811.85
5.4.210.0050.01711.95
5.4.200.0050.01611.89
5.4.190.0030.01811.96
5.4.180.0080.01311.84
5.4.170.0040.01911.91
5.4.160.0090.01711.91
5.4.150.0060.01811.91
5.4.140.0070.02311.83
5.4.130.0070.02111.87
5.4.120.0110.02111.81
5.4.110.0090.01911.83
5.4.100.0050.02211.83
5.4.90.0070.02011.80
5.4.80.0060.02311.82
5.4.70.0040.02511.83
5.4.60.0060.01811.80
5.4.50.0050.02311.79
5.4.40.0080.01911.85
5.4.30.0080.01411.86
5.4.20.0050.02011.75
5.4.10.0030.02011.77
5.4.00.0090.02611.66
5.3.290.0080.01311.98
5.3.280.0060.02511.95
5.3.270.0090.02311.96
5.3.260.0050.02511.95
5.3.250.0040.02411.96
5.3.240.0090.03311.95
5.3.230.0060.02411.95
5.3.220.0080.02211.94
5.3.210.0090.02211.94
5.3.200.0060.02111.94
5.3.190.0060.02211.94
5.3.180.0080.02211.94
5.3.170.0090.01511.94
5.3.160.0070.02011.94
5.3.150.0060.01411.94
5.3.140.0060.01611.94
5.3.130.0040.01811.94
5.3.120.0030.02011.94
5.3.110.0090.01611.93
5.3.100.0050.02111.75
5.3.90.0040.02211.74
5.3.80.0050.02111.74
5.3.70.0080.01911.74
5.3.60.0080.02311.74
5.3.50.0040.02411.72
5.3.40.0050.02011.72
5.3.30.0070.01811.70
5.3.20.0050.01711.62
5.3.10.0050.01511.61
5.3.00.0050.01911.60
5.2.170.0040.0359.15
5.2.160.0060.0309.15
5.2.150.0030.0339.16
5.2.140.0060.0309.15
5.2.130.0040.0339.11
5.2.120.0050.0319.11
5.2.110.0070.0299.11
5.2.100.0050.0329.11
5.2.90.0060.0349.11
5.2.80.0080.0309.11
5.2.70.0040.0379.10
5.2.60.0050.0429.06
5.2.50.0060.0409.03
5.2.40.0050.0429.00
5.2.30.0070.0428.99
5.2.20.0070.0388.97
5.2.10.0070.0398.90
5.2.00.0060.0428.77
5.1.60.0100.0338.05
5.1.50.0080.0268.05
5.1.40.0050.0298.03
5.1.30.0040.0318.37
5.1.20.0080.0298.39
5.1.10.0110.0278.13
5.1.00.0060.0318.13
5.0.50.0050.0226.59
5.0.40.0050.0216.46
5.0.30.0040.0446.27
5.0.20.0040.0216.25
5.0.10.0070.0286.22
5.0.00.0090.0466.21
4.4.90.0040.0234.78
4.4.80.0050.0234.76
4.4.70.0040.0224.76
4.4.60.0030.0274.76
4.4.50.0050.0294.77
4.4.40.0030.0394.71
4.4.30.0070.0194.75
4.4.20.0040.0224.84
4.4.10.0070.0194.85
4.4.00.0040.0334.76
4.3.110.0060.0304.67
4.3.100.0040.0234.67
4.3.90.0040.0224.63
4.3.80.0050.0324.58
4.3.70.0060.0134.63
4.3.60.0050.0164.63
4.3.50.0030.0174.63
4.3.40.0060.0324.54
4.3.30.0020.0243.27
4.3.20.0080.0313.25
4.3.10.0030.0223.21
4.3.00.0230.03010.37

preferences:
61.64 ms | 400 KiB | 5 Q