3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hotels = [ ['Vik', 4, 8.3, 31393], ['Catalonia', 5, 8.4, 33240], ['Ifa', 4, 8.3, 39363], ['Babaro', 5, 8.4, 44059], ['Catalonia Royal', 5, 8.7, 50258], ['Grand Pala', 5, 8.8, 61231], ['Majestic', 5, 8.9, 64693], ['Bilif', 5, 8.0, 68121], ['Nau', 5, 8.5, 72116], ['Paradis', 5, 8.4, 77510], ['Majestic El', 5, 8.9, 80791] ]; $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.0140.00718.31
8.3.50.0150.00322.00
8.3.40.0180.00318.76
8.3.30.0070.00719.29
8.3.20.0040.00420.35
8.3.10.0080.00023.64
8.3.00.0040.01120.75
8.2.180.0160.00016.63
8.2.170.0120.00322.96
8.2.160.0060.00922.20
8.2.150.0080.00024.18
8.2.140.0130.00724.66
8.2.130.0080.00026.16
8.2.120.0090.00922.32
8.2.110.0100.00022.21
8.2.100.0060.00617.83
8.2.90.0060.00319.33
8.2.80.0050.00318.05
8.2.70.0030.00517.62
8.2.60.0040.00418.05
8.2.50.0030.00518.07
8.2.40.0000.00819.51
8.2.30.0000.00818.21
8.2.20.0040.00417.77
8.2.10.0000.00817.93
8.2.00.0000.00917.96
8.1.280.0100.00625.92
8.1.270.0080.00023.94
8.1.260.0080.00026.35
8.1.250.0130.00628.09
8.1.240.0030.00623.74
8.1.230.0090.00319.09
8.1.220.0060.00317.91
8.1.210.0030.00618.77
8.1.200.0000.00817.60
8.1.190.0050.00317.54
8.1.180.0030.00518.10
8.1.170.0090.00018.84
8.1.160.0020.00522.14
8.1.150.0030.00518.81
8.1.140.0050.00317.63
8.1.130.0000.00717.91
8.1.120.0050.00317.59
8.1.110.0080.00017.56
8.1.100.0040.00417.51
8.1.90.0070.00017.60
8.1.80.0040.00417.58
8.1.70.0070.00017.55
8.1.60.0060.00317.77
8.1.50.0080.00017.67
8.1.40.0040.00417.61
8.1.30.0050.00317.66
8.1.20.0030.00617.73
8.1.10.0030.00517.63
8.1.00.0000.01017.68
8.0.300.0070.00018.77
8.0.290.0080.00017.43
8.0.280.0030.00518.57
8.0.270.0110.00017.23
8.0.260.0050.00317.00
8.0.250.0070.00017.11
8.0.240.0090.00017.07
8.0.230.0000.00717.07
8.0.220.0030.00417.09
8.0.210.0000.00717.01
8.0.200.0030.00317.05
8.0.190.0040.00417.12
8.0.180.0050.00317.08
8.0.170.0040.00417.01
8.0.160.0050.00216.90
8.0.150.0000.00716.84
8.0.140.0030.00616.97
8.0.130.0030.00313.46
8.0.120.0040.00416.95
8.0.110.0020.00516.99
8.0.100.0000.00816.81
8.0.90.0020.00517.00
8.0.80.0080.01216.98
8.0.70.0030.00517.01
8.0.60.0080.00016.82
8.0.50.0030.00516.91
8.0.30.0130.00817.09
8.0.20.0090.01117.42
8.0.10.0080.00016.93
8.0.00.0100.01016.81
7.4.330.0000.00515.20
7.4.320.0070.00016.63
7.4.300.0030.00316.62
7.4.290.0000.00716.73
7.4.280.0070.00016.71
7.4.270.0070.00016.73
7.4.260.0040.00416.57
7.4.250.0000.00716.66
7.4.240.0050.00216.62
7.4.230.0000.00816.51
7.4.220.0060.01216.80
7.4.210.0060.01016.74
7.4.200.0030.00316.70
7.4.190.0040.00416.44
7.4.160.0070.01016.91
7.4.150.0090.00917.40
7.4.140.0080.01317.86
7.4.130.0130.00916.64
7.4.120.0120.00916.82
7.4.110.0110.00916.54
7.4.100.0140.00716.61
7.4.90.0060.01616.54
7.4.80.0130.00616.47
7.4.70.0080.00816.65
7.4.60.0180.00316.59
7.4.50.0000.00616.71
7.4.40.0110.00722.77
7.4.30.0150.00316.80
7.4.00.0090.00614.99
7.3.330.0050.00013.43
7.3.320.0030.00313.35
7.3.310.0000.00716.46
7.3.300.0000.00716.52
7.3.290.0030.01016.49
7.3.280.0090.01116.44
7.3.270.0170.00317.40
7.3.260.0100.01616.46
7.3.250.0150.00716.49
7.3.240.0150.00316.38
7.3.230.0140.01216.54
7.3.210.0090.00916.44
7.3.200.0050.01419.39
7.3.190.0120.00616.73
7.3.180.0120.00816.68
7.3.170.0150.00316.64
7.3.160.0140.00316.59
7.3.120.0140.00015.08
7.2.330.0100.01216.83
7.2.320.0110.00816.95
7.2.310.0070.01116.59
7.2.300.0050.01216.67
7.2.290.0050.01516.95
7.2.00.0030.01119.39
7.1.100.0000.01018.04
7.1.70.0000.00717.38
7.1.60.0040.02119.22
7.1.50.0060.01517.10
7.1.00.0030.07722.33
7.0.200.0040.00416.82
7.0.140.0000.07722.00
7.0.60.0030.04019.95
7.0.50.0130.06318.01
7.0.40.0030.05320.16
7.0.30.0570.06720.34
7.0.20.0200.04020.23
7.0.10.0000.06020.23
7.0.00.0130.04720.19
5.6.280.0070.07321.13
5.6.210.0030.08320.68
5.6.200.0030.08318.14
5.6.190.0100.05320.47
5.6.180.0430.08020.63
5.6.170.0270.04020.45
5.6.160.0070.07720.46
5.6.150.0030.08018.18
5.6.140.0100.03718.12
5.6.130.0070.07318.18
5.6.120.0070.03720.89
5.6.110.0030.04021.01
5.6.100.0170.08321.14
5.6.90.0130.07321.14
5.6.80.0170.05720.52
5.5.350.0170.06720.48
5.5.340.0100.05018.05
5.5.330.0070.05320.35
5.5.320.0070.08020.27
5.5.310.0130.04320.30
5.5.300.0100.08017.97
5.5.290.0100.07717.93
5.5.280.0100.03320.82
5.5.270.0170.07320.61
5.5.260.0230.06720.88
5.5.250.0170.05720.70
5.5.240.0200.07020.29
5.4.450.0300.04019.18
5.4.440.1100.04319.41
5.4.430.0530.04719.55
5.4.420.0670.04319.40
5.4.410.0330.03019.43
5.4.400.0730.03019.23
5.4.390.0570.04718.86
5.4.380.0500.07018.73
5.4.370.0270.06318.61
5.4.360.0370.05018.79
5.4.350.0600.07018.61
5.4.340.0270.06018.75
5.4.320.0050.03912.53
5.4.310.0040.04112.53
5.4.300.0080.04212.54
5.4.290.0090.03712.53
5.4.280.0090.04712.40
5.4.270.0040.04312.40
5.4.260.0100.03812.41
5.4.250.0080.04512.40
5.4.240.0070.04112.40
5.4.230.0090.07612.39
5.4.220.0080.06112.39
5.4.210.0140.06912.39
5.4.200.0200.07812.40
5.4.190.0080.08012.39
5.4.180.0130.07512.39
5.4.170.0180.09312.41
5.4.160.0060.04612.40
5.4.150.0170.08312.40
5.4.140.0130.07312.08
5.4.130.0110.04012.07
5.4.120.0070.05112.02
5.4.110.0110.06212.02
5.4.100.0060.04412.02
5.4.90.0120.06412.02
5.4.80.0060.04112.02
5.4.70.0040.03712.02
5.4.60.0060.03712.02
5.4.50.0070.03812.02
5.4.40.0080.05012.00
5.4.30.0110.05712.00
5.4.20.0070.03712.00
5.4.10.0070.03512.00
5.4.00.0080.04111.49
5.3.290.0080.04212.80
5.3.280.0120.04712.71
5.3.270.0120.03912.73
5.3.260.0070.04312.72
5.3.250.0090.03812.72
5.3.240.0070.05112.72
5.3.230.0100.04112.71
5.3.220.0090.04612.68
5.3.210.0070.04012.68
5.3.200.0050.03912.68
5.3.190.0140.04012.68
5.3.180.0050.04712.68
5.3.170.0070.04112.67
5.3.160.0060.03812.68
5.3.150.0080.03712.67
5.3.140.0100.04112.66
5.3.130.0090.05012.66
5.3.120.0100.06212.66
5.3.110.0070.04812.66
5.3.100.0100.04212.12
5.3.90.0030.06112.08
5.3.80.0120.05512.07
5.3.70.0060.04112.08
5.3.60.0050.04312.07
5.3.50.0110.03412.00
5.3.40.0120.03612.00
5.3.30.0040.03811.94
5.3.20.0030.04111.70
5.3.10.0060.04111.67
5.3.00.0080.03811.66
5.2.170.0060.0339.15
5.2.160.0050.0469.15
5.2.150.0030.0339.15
5.2.140.0040.0329.15
5.2.130.0060.0279.11
5.2.120.0120.0459.11
5.2.110.0150.0499.12
5.2.100.0090.0689.12
5.2.90.0070.0349.11
5.2.80.0070.0349.11
5.2.70.0150.0549.11
5.2.60.0050.0329.06
5.2.50.0040.0339.03
5.2.40.0110.0459.00
5.2.30.0150.0638.98
5.2.20.0060.0368.98
5.2.10.0080.0278.90
5.2.00.0040.0328.77
5.1.60.0040.0328.04
5.1.50.0050.0288.05
5.1.40.0080.0298.03
5.1.30.0060.0318.38
5.1.20.0100.0548.40
5.1.10.0110.0628.12
5.1.00.0130.0408.13
5.0.50.0080.0276.59
5.0.40.0090.0516.46
5.0.30.0070.0516.27
5.0.20.0100.0456.25
5.0.10.0140.0356.22
5.0.00.0130.0836.21
4.4.90.0090.0544.78
4.4.80.0060.0404.76
4.4.70.0110.0354.75
4.4.60.0090.0454.76
4.4.50.0140.0414.77
4.4.40.0040.0564.71
4.4.30.0070.0344.76
4.4.20.0100.0364.84
4.4.10.0120.0394.85
4.4.00.0100.0744.76
4.3.110.0040.0284.67
4.3.100.0030.0164.66
4.3.90.0050.0244.63
4.3.80.0040.0314.58
4.3.70.0060.0304.63
4.3.60.0060.0264.63
4.3.50.0100.0374.63
4.3.40.0040.0394.54
4.3.30.0100.0323.27
4.3.20.0060.0443.25
4.3.10.0050.0363.22
4.3.00.0100.01015.47

preferences:
46.68 ms | 401 KiB | 5 Q