3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Aloft', 4, 8.3, 24756], ['The bestian', 5, 8.0, 26553], ['The royal', 5, 8.2, 32226], ['Royal cariben', 5, 8.3, 33886], ['Kristal', 4, 8.1, 35551], ['Fiesta', 5, 8.2, 38221], ['Presidenta', 5, 8.3, 38500], ['The lagun amar', 5, 8.8, 41454], ['Casa Maya', 5, 8.1, 46518], ['Casa Magna', 4, 8.8, 47408], ['Americana', 5, 9.2, 59580], ]; $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.60.0080.00816.75
8.3.50.0130.00622.00
8.3.40.0150.00018.79
8.3.30.0060.01019.21
8.3.20.0000.00820.34
8.3.10.0080.00023.61
8.3.00.0060.00319.43
8.2.180.0140.00716.75
8.2.170.0120.00322.96
8.2.160.0040.01120.52
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0060.00326.16
8.2.120.0070.00419.13
8.2.110.0090.00022.33
8.2.100.0090.00318.03
8.2.90.0030.00619.34
8.2.80.0050.00318.05
8.2.70.0090.00017.75
8.2.60.0030.00518.16
8.2.50.0000.00918.07
8.2.40.0050.00518.09
8.2.30.0040.00418.32
8.2.20.0070.00017.86
8.2.10.0050.00218.21
8.2.00.0040.00417.87
8.1.280.0090.00625.92
8.1.270.0040.00422.30
8.1.260.0050.00326.35
8.1.250.0030.00528.09
8.1.240.0060.00323.97
8.1.230.0100.00019.35
8.1.220.0090.00017.93
8.1.210.0080.00018.77
8.1.200.0030.00717.73
8.1.190.0030.00517.54
8.1.180.0000.00919.01
8.1.170.0030.00618.76
8.1.160.0050.00222.20
8.1.150.0080.00018.84
8.1.140.0000.00717.60
8.1.130.0040.00417.96
8.1.120.0040.00417.55
8.1.110.0000.00817.62
8.1.100.0100.00017.60
8.1.90.0040.00417.51
8.1.80.0040.00417.59
8.1.70.0040.00417.45
8.1.60.0030.00517.60
8.1.50.0060.00317.69
8.1.40.0030.00617.68
8.1.30.0000.00817.71
8.1.20.0040.00417.82
8.1.10.0040.00417.54
8.1.00.0040.00417.56
8.0.300.0080.00018.90
8.0.290.0040.00417.18
8.0.280.0030.00318.57
8.0.270.0040.00417.39
8.0.260.0000.00617.30
8.0.250.0070.00017.04
8.0.240.0000.00717.08
8.0.230.0070.00017.04
8.0.220.0050.00316.95
8.0.210.0000.00717.02
8.0.200.0070.00017.01
8.0.190.0030.00517.09
8.0.180.0030.00517.05
8.0.170.0040.00416.97
8.0.160.0030.00516.98
8.0.150.0000.00716.94
8.0.140.0040.00417.03
8.0.130.0000.00713.42
8.0.120.0040.00416.96
8.0.110.0040.00416.99
8.0.100.0040.00416.84
8.0.90.0040.00416.92
8.0.80.0100.01016.93
8.0.70.0020.00517.01
8.0.60.0000.00716.89
8.0.50.0050.00316.96
8.0.30.0080.01317.25
8.0.20.0080.01417.40
8.0.10.0060.00317.14
8.0.00.0130.01116.90
7.4.330.0050.00215.00
7.4.320.0060.00016.63
7.4.300.0000.00616.70
7.4.290.0000.00716.77
7.4.280.0030.00316.63
7.4.270.0000.00716.63
7.4.260.0030.00516.66
7.4.250.0070.00016.61
7.4.240.0060.00116.67
7.4.230.0030.00316.60
7.4.220.0100.01616.82
7.4.210.0080.00916.69
7.4.200.0040.00416.62
7.4.190.0000.00716.86
7.4.160.0110.01116.68
7.4.150.0070.01117.40
7.4.140.0120.00617.86
7.4.130.0110.01016.57
7.4.120.0110.01116.72
7.4.110.0040.01416.50
7.4.100.0080.01116.54
7.4.90.0060.01216.58
7.4.80.0190.00319.39
7.4.70.0120.00816.68
7.4.60.0140.00516.40
7.4.50.0050.00016.35
7.4.40.0070.01022.77
7.4.30.0080.00816.42
7.4.10.0150.00314.72
7.4.00.0070.01014.99
7.3.330.0030.00313.49
7.3.320.0000.00513.52
7.3.310.0040.00416.34
7.3.300.0000.00716.36
7.3.290.0000.01516.41
7.3.280.0120.00716.48
7.3.270.0080.01217.40
7.3.260.0130.00616.54
7.3.250.0100.00916.72
7.3.240.0080.01216.55
7.3.230.0160.00716.72
7.3.210.0070.01116.64
7.3.200.0120.00619.39
7.3.190.0080.01216.70
7.3.180.0090.00916.71
7.3.170.0090.00916.71
7.3.160.0070.01216.60
7.3.130.0130.00715.02
7.3.120.0070.01014.89
7.3.110.0070.00914.74
7.3.100.0070.00815.00
7.3.90.0090.00614.84
7.3.80.0120.00314.88
7.3.70.0030.00814.89
7.3.60.0060.00814.82
7.3.50.0090.00214.56
7.3.40.0030.01214.59
7.3.30.0100.00314.72
7.3.20.0080.00616.50
7.3.10.0080.00716.33
7.3.00.0090.00616.45
7.2.330.0090.01016.84
7.2.320.0100.00916.85
7.2.310.0150.00616.88
7.2.300.0080.00816.61
7.2.290.0060.01216.71
7.2.260.0060.01315.19
7.2.250.0070.01314.81
7.2.240.0100.00815.07
7.2.230.0110.00515.19
7.2.220.0020.00815.09
7.2.210.0100.00615.06
7.2.200.0100.00515.00
7.2.190.0050.00914.97
7.2.180.0060.00615.04
7.2.170.0060.00415.01
7.2.160.0000.00914.66
7.2.150.0070.00716.92
7.2.140.0070.00716.82
7.2.130.0000.01616.88
7.2.120.0100.01016.94
7.2.110.0100.01016.83
7.2.100.0120.00616.92
7.2.90.0060.00916.57
7.2.80.0060.01217.07
7.2.70.0130.00616.69
7.2.60.0030.00716.73
7.2.50.0030.01416.62
7.2.40.0060.01216.92
7.2.30.0030.01717.04
7.2.20.0080.00716.77
7.2.10.0000.01916.81
7.2.00.0050.00818.19
7.1.330.0090.00415.82
7.1.320.0070.00915.75
7.1.310.0000.01215.82
7.1.300.0080.00615.73
7.1.290.0060.00615.71
7.1.280.0050.00815.82
7.1.270.0070.00715.66
7.1.260.0040.00915.80
7.1.250.0040.00715.62
7.1.240.0120.00815.44
7.1.230.0110.00815.61
7.1.220.0070.01115.77
7.1.210.0070.00715.79
7.1.200.0060.00915.82
7.1.190.0080.00415.85
7.1.180.0090.00615.47
7.1.170.0090.00615.63
7.1.160.0070.00715.86
7.1.150.0150.00015.88
7.1.140.0060.01215.99
7.1.130.0100.00715.91
7.1.120.0030.00815.73
7.1.110.0070.00715.52
7.1.100.0060.00716.82
7.1.90.0120.00315.88
7.1.80.0040.00815.84
7.1.70.0000.01116.40
7.1.60.0050.01417.51
7.1.50.0050.01016.47
7.1.40.0000.01515.66
7.1.30.0060.00915.47
7.1.20.0000.01215.81
7.1.10.0090.00315.79
7.1.00.0050.04319.09
7.0.330.0040.00415.11
7.0.320.0030.01415.22
7.0.310.0090.00915.10
7.0.300.0100.00715.18
7.0.290.0070.00715.34
7.0.280.0030.01514.97
7.0.270.0030.01315.07
7.0.260.0030.01015.20
7.0.250.0090.00615.45
7.0.240.0060.00615.57
7.0.230.0100.00315.39
7.0.220.0070.00715.40
7.0.210.0070.00715.42
7.0.200.0000.00816.11
7.0.190.0120.00315.50
7.0.180.0060.00915.40
7.0.170.0030.01315.40
7.0.160.0040.00815.11
7.0.150.0060.00915.45
7.0.140.0030.04118.65
7.0.130.0040.00815.25
7.0.120.0000.01015.41
7.0.110.0000.01515.41
7.0.100.0030.00615.43
7.0.90.0030.01015.48
7.0.80.0080.00415.34
7.0.70.0030.00615.31
7.0.60.0030.02217.45
7.0.50.0070.04416.73
7.0.40.0030.02716.84
7.0.30.0280.04016.92
7.0.20.0180.04116.81
7.0.10.0070.03516.91
7.0.00.0100.02516.82
5.6.400.0140.00314.69
5.6.390.0050.00814.06
5.6.380.0140.00413.88
5.6.370.0100.00614.61
5.6.360.0000.01214.45
5.6.350.0060.00614.46
5.6.340.0060.01014.18
5.6.330.0100.00714.38
5.6.320.0000.01114.70
5.6.310.0030.01314.41
5.6.300.0070.00714.07
5.6.290.0100.00314.49
5.6.280.0020.04417.64
5.6.270.0120.00314.60
5.6.260.0030.01014.39
5.6.250.0040.01514.16
5.6.240.0000.01614.47
5.6.230.0000.01114.20
5.6.220.0070.00614.30
5.6.210.0050.04617.55
5.6.200.0000.02916.22
5.6.190.0070.05217.35
5.6.180.0180.04217.53
5.6.170.0170.04017.54
5.6.160.0020.02717.36
5.6.150.0100.04316.21
5.6.140.0030.05016.22
5.6.130.0080.04016.29
5.6.120.0110.04017.83
5.6.110.0020.04517.74
5.6.100.0060.03617.64
5.6.90.0090.03617.64
5.6.80.0100.02717.19
5.6.70.1970.02017.23
5.6.60.0030.01314.05
5.6.50.0030.01214.32
5.6.40.0090.00614.56
5.6.30.0050.00514.31
5.6.20.0030.00914.47
5.6.10.0030.00914.34
5.6.00.0060.00314.29
5.5.380.0030.01214.59
5.5.370.0040.00814.43
5.5.360.0090.00614.22
5.5.350.0110.04517.37
5.5.340.0090.04016.06
5.5.330.0100.03717.13
5.5.320.0040.02717.45
5.5.310.0120.04617.30
5.5.300.0060.04516.22
5.5.290.0060.03916.00
5.5.280.0070.04717.49
5.5.270.0070.03617.38
5.5.260.0100.04317.63
5.5.250.0050.02617.44
5.5.240.0170.03217.35
5.5.230.0000.01014.18
5.5.220.0040.01114.04
5.5.210.0030.01014.32
5.5.200.0090.00614.25
5.5.190.0060.00314.16
5.5.180.0110.00014.05
5.5.170.0030.01013.85
5.5.160.0040.00714.08
5.5.150.0060.00614.08
5.5.140.0000.01014.19
5.5.130.0110.00314.53
5.5.120.0070.00313.99
5.5.110.0120.00314.59
5.5.100.0000.01714.16
5.5.90.0040.01113.99
5.5.80.0070.00714.60
5.5.70.0110.00314.12
5.5.60.0030.00914.09
5.5.50.0070.00413.96
5.5.40.0000.01314.07
5.5.30.0030.01313.98
5.5.20.0060.00314.12
5.5.10.0000.01013.89
5.5.00.0070.00713.95
5.4.450.0180.03415.47
5.4.440.0270.03715.48
5.4.430.0480.03215.30
5.4.420.0180.03515.48
5.4.410.0450.03315.47
5.4.400.0080.03215.17
5.4.390.0330.02314.99
5.4.380.0150.03514.94
5.4.370.0220.03714.86
5.4.360.0170.03815.08
5.4.350.0180.04114.89
5.4.340.0190.03514.86
5.4.330.0000.01111.31
5.4.320.0020.02311.94
5.4.310.0060.02711.93
5.4.300.0060.02211.94
5.4.290.0030.03011.81
5.4.280.0060.03111.76
5.4.270.0070.02811.66
5.4.260.0050.03311.64
5.4.250.0140.04211.79
5.4.240.0100.03211.89
5.4.230.0100.02711.66
5.4.220.0090.02611.70
5.4.210.0080.03111.88
5.4.200.0050.03811.82
5.4.190.0030.03311.86
5.4.180.0040.03511.83
5.4.170.0080.02911.79
5.4.160.0080.02511.78
5.4.150.0070.03111.74
5.4.140.0060.03511.65
5.4.130.0120.04911.67
5.4.120.0050.04711.63
5.4.110.0070.03211.45
5.4.100.0070.02611.57
5.4.90.0080.02111.46
5.4.80.0060.02211.59
5.4.70.0090.03411.46
5.4.60.0060.03511.58
5.4.50.0040.02611.45
5.4.40.0040.02511.56
5.4.30.0040.02411.46
5.4.20.0080.02211.44
5.4.10.0090.02111.60
5.4.00.0080.02711.37
5.3.290.0040.02611.49
5.3.280.0070.03811.45
5.3.270.0080.02711.41
5.3.260.0050.02411.47
5.3.250.0090.03211.45
5.3.240.0050.03411.41
5.3.230.0070.02111.35
5.3.220.0060.02711.37
5.3.210.0100.04111.44
5.3.200.0100.03411.40
5.3.190.0050.03011.42
5.3.180.0100.03111.51
5.3.170.0050.03111.46
5.3.160.0070.04111.40
5.3.150.0090.03011.46
5.3.140.0070.03011.42
5.3.130.0090.02911.42
5.3.120.0060.03111.44
5.3.110.0070.03111.45
5.3.100.0090.02911.20
5.3.90.0100.02311.19
5.3.80.0050.02511.12
5.3.70.0070.02111.14
5.3.60.0070.02511.14
5.3.50.0090.02411.05
5.3.40.0070.02811.06
5.3.30.0050.02011.01
5.3.20.0060.02210.80
5.3.10.0040.02010.78
5.3.00.0020.02610.80
5.2.170.0050.0329.16
5.2.160.0080.0419.16
5.2.150.0130.0439.16
5.2.140.0090.0509.15
5.2.130.0090.0459.11
5.2.120.0090.0519.11
5.2.110.0090.0389.11
5.2.100.0090.0429.11
5.2.90.0050.0459.11
5.2.80.0090.0299.12
5.2.70.0080.0429.11
5.2.60.0070.0469.06
5.2.50.0150.0329.03
5.2.40.0080.0479.00
5.2.30.0050.0448.98
5.2.20.0140.0588.98
5.2.10.0130.0418.90
5.2.00.0040.0368.76
5.1.60.0050.0368.04
5.1.50.0040.0358.04
5.1.40.0060.0348.03
5.1.30.0000.0328.38
5.1.20.0020.0288.40
5.1.10.0060.0258.12
5.1.00.0040.0298.12
5.0.50.0070.0226.60
5.0.40.0020.0236.46
5.0.30.0040.0406.27
5.0.20.0050.0256.25
5.0.10.0010.0236.22
5.0.00.0050.0296.21
4.4.90.0040.0164.78
4.4.80.0040.0154.75
4.4.70.0030.0164.75
4.4.60.0030.0164.75
4.4.50.0020.0174.77
4.4.40.0070.0304.71
4.4.30.0100.0164.76
4.4.20.0020.0234.85
4.4.10.0030.0234.85
4.4.00.0030.0344.76
4.3.110.0040.0224.67
4.3.100.0020.0264.66
4.3.90.0070.0194.64
4.3.80.0040.0314.59
4.3.70.0040.0204.63
4.3.60.0040.0264.63
4.3.50.0040.0214.63
4.3.40.0020.0254.54
4.3.30.0010.0173.27
4.3.20.0030.0153.25
4.3.10.0020.0163.21
4.3.00.0130.01310.37

preferences:
52.38 ms | 401 KiB | 5 Q