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], ]; $top = [ 'Ocean', 'Ya', 'Chaba', ]; for ( $i=0; $i<count($hotels); $i++ ) { $hotels[$i][4] = 0; } var_dump(buildTop($hotels, 0.2, 2000)); function buildTop($hotels, $starCoef, $ratingCoef) { for ( $i=0; $i<count($hotels); $i++ ) { for ( $j=$i+1; $j<count($hotels); $j++ ) { $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); if ( $price < $hotels[$j][3] ) { $hotels[$i][4]++; } else { $hotels[$j][4]++; } } } usort($hotels, function($hotelA, $hotelB){ return $hotelB[4]-$hotelA[4]; }); return array_map(function($hotel){ return $hotel[0]; }, $hotels); }

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.0110.01118.45
8.3.50.0150.00521.99
8.3.40.0070.00719.02
8.3.30.0100.01018.61
8.3.20.0050.00318.85
8.3.10.0000.00821.26
8.3.00.0050.00323.63
8.2.180.0070.01416.88
8.2.170.0090.00922.96
8.2.160.0090.00620.56
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00019.89
8.2.110.0070.00322.24
8.2.100.0120.00017.71
8.2.90.0000.00819.11
8.2.80.0000.00818.16
8.2.70.0050.00317.63
8.2.60.0030.00518.16
8.2.50.0040.00418.07
8.2.40.0000.00818.41
8.2.30.0000.00821.24
8.2.20.0000.00917.76
8.2.10.0070.00017.95
8.2.00.0040.00417.74
8.1.280.0120.00625.92
8.1.270.0070.00023.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0100.00022.67
8.1.230.0070.00420.89
8.1.220.0040.00418.77
8.1.210.0060.00318.95
8.1.200.0000.00817.35
8.1.190.0000.00817.63
8.1.180.0070.00318.10
8.1.170.0030.00518.65
8.1.160.0040.00418.84
8.1.150.0040.00418.78
8.1.140.0020.00517.54
8.1.130.0030.00317.91
8.1.120.0050.00217.45
8.1.110.0030.00517.40
8.1.100.0060.00317.57
8.1.90.0040.00417.38
8.1.80.0000.00717.43
8.1.70.0000.00717.56
8.1.60.0040.00417.56
8.1.50.0040.00417.46
8.1.40.0060.00317.42
8.1.30.0000.00717.63
8.1.20.0040.00417.70
8.1.10.0070.00017.71
8.1.00.0050.00317.56
8.0.300.0000.00720.01
8.0.290.0040.00416.75
8.0.280.0000.00718.59
8.0.270.0070.00017.24
8.0.260.0030.00316.89
8.0.250.0030.00517.00
8.0.240.0000.01016.92
8.0.230.0090.00017.02
8.0.220.0000.00716.78
8.0.210.0040.00416.86
8.0.200.0030.00617.05
8.0.190.0040.00417.07
8.0.180.0000.00716.85
8.0.170.0030.00416.92
8.0.160.0000.00816.98
8.0.150.0030.00516.89
8.0.140.0000.00716.85
8.0.130.0060.00013.44
8.0.120.0060.00316.92
8.0.110.0000.00716.84
8.0.100.0040.00417.03
8.0.90.0000.00717.00
8.0.80.0120.00316.91
8.0.70.0000.00817.00
8.0.60.0000.00717.02
8.0.50.0000.00716.92
8.0.30.0080.01117.26
8.0.20.0120.01117.40
8.0.10.0040.00417.11
8.0.00.0140.00816.75
7.4.330.0000.00513.43
7.4.320.0000.00616.51
7.4.300.0060.00016.47
7.4.290.0030.00316.59
7.4.280.0040.00416.58
7.4.270.0000.00916.45
7.4.260.0030.00313.42
7.4.250.0000.00716.69
7.4.240.0030.00316.56
7.4.230.0040.00416.38
7.4.220.0180.00016.61
7.4.210.0070.01016.63
7.4.200.0000.00716.42
7.4.190.0070.00016.84
7.4.160.0100.01016.59
7.4.150.0150.00617.40
7.4.140.0110.01317.86
7.4.130.0120.00916.50
7.4.120.0120.00616.51
7.4.110.0070.01016.52
7.4.100.0150.00316.60
7.4.90.0070.01616.69
7.4.80.0070.01419.39
7.4.70.0060.01616.49
7.4.60.0070.01016.56
7.4.50.0030.00616.28
7.4.40.0060.00922.52
7.4.30.0080.00816.65
7.4.00.0050.01215.02
7.3.330.0020.00213.45
7.3.320.0000.00613.21
7.3.310.0040.00416.43
7.3.300.0040.00416.34
7.3.290.0120.00916.46
7.3.280.0070.01116.44
7.3.270.0040.01317.40
7.3.260.0070.01118.24
7.3.250.0110.01016.49
7.3.240.0140.00616.69
7.3.230.0170.00016.63
7.3.210.0110.00616.66
7.3.200.0150.00719.39
7.3.190.0100.01316.40
7.3.180.0130.00316.27
7.3.170.0140.00316.62
7.3.160.0080.00816.69
7.3.120.0040.01214.86
7.3.110.0050.01114.90
7.3.100.0090.00614.90
7.3.90.0090.00614.84
7.3.80.0070.00714.80
7.3.70.0030.00914.89
7.3.60.0100.00614.84
7.3.50.0050.00714.76
7.3.40.0030.01014.77
7.3.30.0080.00614.63
7.3.20.0060.00416.68
7.3.10.0040.01016.66
7.3.00.0070.00816.54
7.2.330.0090.00916.78
7.2.320.0110.01216.81
7.2.310.0120.01216.86
7.2.300.0030.01416.77
7.2.290.0180.00016.70
7.2.250.0060.01114.91
7.2.240.0100.00915.02
7.2.230.0060.00715.15
7.2.220.0070.00715.12
7.2.210.0080.00814.94
7.2.200.0040.01015.08
7.2.190.0090.00715.09
7.2.180.0080.00514.90
7.2.170.0020.01015.13
7.2.160.0070.01014.98
7.2.150.0090.00617.02
7.2.140.0080.00416.90
7.2.130.0030.01216.77
7.2.120.0070.01116.95
7.2.110.0150.00016.71
7.2.100.0030.01316.96
7.2.90.0000.01017.05
7.2.80.0140.00316.95
7.2.70.0070.01017.09
7.2.60.0070.01016.97
7.2.50.0100.00317.00
7.2.40.0070.00317.08
7.2.30.0130.00316.68
7.2.20.0090.00616.94
7.2.10.0080.00816.96
7.2.00.0040.00818.22
7.1.330.0090.00515.73
7.1.320.0050.00915.68
7.1.310.0080.00515.71
7.1.300.0070.00515.82
7.1.290.0060.00615.68
7.1.280.0050.00615.78
7.1.270.0060.00815.58
7.1.260.0020.01215.74
7.1.250.0030.01315.99
7.1.240.0070.00715.52
7.1.230.0060.00915.78
7.1.220.0030.01415.66
7.1.210.0030.01015.55
7.1.200.0030.00915.71
7.1.190.0030.01715.88
7.1.180.0110.00815.86
7.1.170.0060.00615.98
7.1.160.0090.00615.87
7.1.150.0030.01315.68
7.1.140.0000.01115.66
7.1.130.0000.01215.93
7.1.120.0100.00015.45
7.1.110.0070.01315.66
7.1.100.0040.00717.14
7.1.90.0000.01415.90
7.1.80.0050.00815.60
7.1.70.0060.00516.39
7.1.60.0070.01017.48
7.1.50.0080.01116.37
7.1.40.0040.00415.65
7.1.30.0100.00315.53
7.1.20.0030.00715.96
7.1.10.0030.00715.82
7.1.00.0070.03819.13
7.0.330.0030.01115.23
7.0.320.0030.01415.44
7.0.310.0040.01115.45
7.0.300.0040.00715.19
7.0.290.0000.00815.53
7.0.280.0070.00715.19
7.0.270.0100.00715.41
7.0.260.0070.01315.45
7.0.250.0040.00815.22
7.0.240.0060.00615.37
7.0.230.0040.00815.42
7.0.220.0030.01015.11
7.0.210.0080.00415.43
7.0.200.0020.00515.93
7.0.190.0090.00615.56
7.0.180.0120.00315.39
7.0.170.0000.01115.54
7.0.160.0000.01415.53
7.0.150.0040.01115.53
7.0.140.0020.04418.72
7.0.130.0030.00815.52
7.0.120.0030.01015.50
7.0.110.0060.02517.54
7.0.100.0080.04017.72
7.0.90.0030.05717.74
7.0.80.0070.02117.57
7.0.70.0030.02217.74
7.0.60.0020.02517.76
7.0.50.0050.02817.82
7.0.40.0030.02816.69
7.0.30.0030.04016.60
7.0.20.0050.03016.65
7.0.10.0010.02416.58
7.0.00.0070.03216.67
5.6.400.0030.01314.46
5.6.390.0040.01114.32
5.6.380.0080.00514.60
5.6.370.0030.00714.75
5.6.360.0060.00614.39
5.6.350.0090.00014.39
5.6.340.0000.01314.72
5.6.330.0060.00614.31
5.6.320.0000.01113.94
5.6.310.0030.00914.44
5.6.300.0070.01014.46
5.6.290.0030.00614.36
5.6.280.0030.04317.91
5.6.270.0090.00614.29
5.6.260.0090.02517.64
5.6.250.0040.02617.78
5.6.240.0100.03517.70
5.6.230.0020.02417.41
5.6.220.0030.03017.50
5.6.210.0030.02717.55
5.6.200.0110.03017.55
5.6.190.0060.03017.48
5.6.180.0070.04717.41
5.6.170.0090.03117.49
5.6.160.0030.02517.65
5.6.150.0030.03617.49
5.6.140.0050.04217.49
5.6.130.0080.03817.54
5.6.120.0050.03617.65
5.6.110.0060.02817.39
5.6.100.0080.02117.66
5.6.90.0070.02517.58
5.6.80.0020.03717.14
5.6.70.0060.01817.12
5.6.60.0030.02617.26
5.6.50.0050.02117.10
5.6.40.0020.02417.14
5.6.30.0050.02117.25
5.6.20.0000.02617.28
5.6.10.0020.04217.18
5.6.00.0080.05017.17
5.5.380.0070.03116.02
5.5.370.0030.02215.83
5.5.360.0050.03616.03
5.5.350.0050.03416.08
5.5.340.0030.03216.21
5.5.330.0060.04016.32
5.5.320.0020.02516.17
5.5.310.0020.03016.34
5.5.300.0080.03016.07
5.5.290.0020.02716.27
5.5.280.0110.03315.99
5.5.270.0050.04516.23
5.5.260.0050.03516.29
5.5.250.0050.04216.25
5.5.240.0030.02815.97
5.5.230.0050.02515.98
5.5.220.0050.02415.80
5.5.210.0030.02315.75
5.5.200.0040.03515.82
5.5.190.0060.02115.96
5.5.180.0100.03315.98
5.5.170.0070.00714.56
5.5.160.0020.02715.80
5.5.150.0040.02515.90
5.5.140.0070.04215.87
5.5.130.0050.02015.67
5.5.120.0020.03715.77
5.5.110.0100.01815.90
5.5.100.0050.02615.89
5.5.90.0040.02215.92
5.5.80.0040.02215.73
5.5.70.0050.02115.93
5.5.60.0080.02215.80
5.5.50.0060.02915.69
5.5.40.0070.03516.01
5.5.30.0070.03915.82
5.5.20.0100.03215.77
5.5.10.0050.02515.84
5.5.00.0050.02215.72
5.4.450.0060.02015.91
5.4.440.0020.03015.90
5.4.430.0050.04315.86
5.4.420.0020.04015.86
5.4.410.0030.02215.68
5.4.400.0070.02215.61
5.4.390.0060.01915.65
5.4.380.0050.02415.61
5.4.370.0050.02015.61
5.4.360.0070.01815.65
5.4.350.0070.01915.69
5.4.340.0050.03015.59
5.4.330.0070.00012.16
5.4.320.0050.03815.61
5.4.310.0030.03515.63
5.4.300.0050.02815.70
5.4.290.0040.02215.67
5.4.280.0040.02915.70
5.4.270.0030.02015.73
5.4.260.0070.01715.69
5.4.250.0060.01815.60
5.4.240.0060.01915.58
5.4.230.0090.02415.74
5.4.220.0050.02115.69
5.4.210.0000.02615.58
5.4.200.0070.02315.65
5.4.190.0070.01915.73
5.4.180.0030.03315.74
5.4.170.0030.02315.58
5.4.160.0020.02315.66
5.4.150.0050.02215.60
5.4.140.0080.02114.33
5.4.130.0080.03314.42
5.4.120.0070.03714.36
5.4.110.0000.04014.39
5.4.100.0050.03014.30
5.4.90.0070.01714.39
5.4.80.0050.02214.38
5.4.70.0050.03114.35
5.4.60.0070.03214.29
5.4.50.0040.03614.28
5.4.40.0030.03714.38
5.4.30.0050.02714.35
5.4.20.0050.01614.25
5.4.10.0040.03914.36
5.4.00.0020.03614.01
5.3.290.0010.02113.46
5.3.280.0050.02613.35
5.3.270.0080.03813.28
5.3.260.0030.02313.38
5.3.250.0040.02913.32
5.3.240.0030.02113.36
5.3.230.0020.03913.27
5.3.220.0030.02113.41
5.3.210.0080.03313.33
5.3.200.0060.03113.30
5.3.190.0030.03513.29
5.3.180.0030.04313.33
5.3.170.0020.02813.33
5.3.160.0050.03813.34
5.3.150.0030.03513.39
5.3.140.0020.04113.33
5.3.130.0030.04013.28
5.3.120.0090.02913.25
5.3.110.0030.01813.33
5.3.100.0050.03813.07
5.3.90.0070.03712.99
5.3.80.0060.03613.02
5.3.70.0060.04113.03
5.3.60.0030.03013.00
5.3.50.0050.02613.01
5.3.40.0040.03513.09
5.3.30.0050.03213.04
5.3.20.0020.02012.82
5.3.10.0030.02012.88
5.3.00.0080.02812.87
5.2.170.0070.06312.23
5.2.160.0070.05312.23
5.2.150.0070.02312.23
5.2.140.0030.03012.23
5.2.130.0000.03012.23
5.2.120.0000.02712.23
5.2.110.0130.06012.23
5.2.100.0030.05312.23
5.2.90.0130.05012.23
5.2.80.0100.05712.23
5.2.70.0100.05312.23
5.2.60.0070.02712.23
5.2.50.0100.02312.23
5.2.40.0100.05012.23
5.2.30.0030.02712.23
5.2.20.0070.06312.23
5.2.10.0030.03012.23
5.2.00.0030.05712.23
5.1.60.0070.04712.23
5.1.50.0000.02712.23
5.1.40.0070.01712.23
5.1.30.0000.02712.23
5.1.20.0030.02312.23
5.1.10.0000.02712.23
5.1.00.0070.02712.23
5.0.50.0000.02312.23
5.0.40.0100.03712.23
5.0.30.0030.02712.23
5.0.20.0000.02012.23
5.0.10.0100.01312.23
5.0.00.0030.05312.23
4.4.90.0030.02012.23
4.4.80.0000.01312.23
4.4.70.0030.03312.23
4.4.60.0000.04312.23
4.4.50.0070.03012.23
4.4.40.0000.05012.23
4.4.30.0000.03012.23
4.4.20.0070.01012.23
4.4.10.0000.01712.23
4.4.00.0000.03012.23
4.3.110.0000.01712.23
4.3.100.0000.01712.23
4.3.90.0030.01012.23
4.3.80.0000.04012.23
4.3.70.0000.01312.23
4.3.60.0030.03012.23
4.3.50.0000.02312.23
4.3.40.0030.03312.23
4.3.30.0000.03312.23
4.3.20.0000.03012.23
4.3.10.0000.01712.23
4.3.00.0000.02712.23

preferences:
59.19 ms | 401 KiB | 5 Q