3v4l.org

run code in 300+ PHP versions simultaneously
<? $expectedAmount = 13460.39; $arr = array(1090, 800, 293, 456.35,483.6,5766,1295,424,2005.15,944.5,7100,6800,7100); // Only modify above lines function printCombination($arr, $n, $r, &$result) { $data = array(); // int data[r]; combinationUtil($arr, $data, 0, $n-1, 0 ,$r, $result); } function combinationUtil($arr, $data, $start, $end, $index, $r, &$result) { if ($index == $r) { $tmpArray = array(); for ($i = 0; $i < $r; $i++) { array_push($tmpArray, $data[$i]); // echo $data[$i]; } // echo "<br>"; array_push($result, $tmpArray); return; } for ($i = $start; $i <= $end && $end - $i +1 >= $r - $index; $i++) { $data[$index] = $arr[$i]; combinationUtil($arr, $data, $i+1, $end, $index+1, $r, $result); } } function printValue($arr) { $string = ""; foreach ($arr as $value) { $string .= "$".$value.", "; } echo substr($string, 0, strlen($string)-2); } $result = array(); $n = sizeof($arr)/sizeof($arr[0]); for ($i = 1; $i <= $n; $i++) { printCombination($arr, $n, $i, $result); } $highestAmount = 0; $highestCombination = NULL; foreach ($result as $value) { $tempAmount = 0; foreach ($value as $cost) { $tempAmount += $cost; } if ($tempAmount > $highestAmount && $expectedAmount > $tempAmount) { $highestAmount = $tempAmount; $highestCombination = $value; } } echo "highestAmount: ". $highestAmount."\n"; echo "highestCombination: "; printValue($highestCombination); ?>

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.0120.00618.43
8.3.50.0130.01016.46
8.3.40.0070.00718.84
8.3.30.0090.00618.53
8.3.20.0050.00220.20
8.3.10.0090.00021.89
8.3.00.0080.00019.67
8.2.180.0130.00316.32
8.2.170.0060.01022.96
8.2.160.0000.01419.09
8.2.150.0040.00424.18
8.2.140.0000.00724.66
8.2.130.0050.00219.15
8.2.120.0070.00026.35
8.2.110.0030.00620.52
8.2.100.0110.00017.66
8.2.90.0000.00819.09
8.2.80.0000.00817.97
8.2.70.0130.00017.25
8.2.60.0040.00417.80
8.2.50.0030.00618.10
8.2.40.0040.00420.59
8.2.30.0050.00220.90
8.2.20.0000.00717.90
8.2.10.0070.00018.00
8.2.00.0040.00418.02
8.1.280.0160.00725.92
8.1.270.0040.00422.11
8.1.260.0070.00026.35
8.1.250.0070.00028.09
8.1.240.0060.00323.84
8.1.230.0040.00719.22
8.1.220.0060.00317.74
8.1.210.0040.00418.77
8.1.200.0030.00617.13
8.1.190.0000.00817.10
8.1.180.0030.00518.10
8.1.170.0040.00419.02
8.1.160.0040.00418.96
8.1.150.0030.00620.54
8.1.140.0030.00519.37
8.1.130.0000.00818.77
8.1.120.0030.00517.38
8.1.110.0080.00017.25
8.1.100.0000.00717.33
8.1.90.0080.00017.24
8.1.80.0030.00517.30
8.1.70.0000.00717.23
8.1.60.0040.00417.36
8.1.50.0020.00517.42
8.1.40.0000.00817.33
8.1.30.0060.00317.36
8.1.20.0040.00417.40
8.1.10.0030.00517.44
8.1.00.0050.00217.43
8.0.300.0000.00720.14
8.0.290.0040.00416.75
8.0.280.0000.00818.29
8.0.270.0000.00717.21
8.0.260.0000.00616.77
8.0.250.0070.00016.75
8.0.240.0040.00416.75
8.0.230.0000.01016.84
8.0.220.0000.00816.73
8.0.210.0000.00716.68
8.0.200.0070.00016.86
8.0.190.0030.00516.87
8.0.180.0040.00416.82
8.0.170.0000.00716.76
8.0.160.0040.00416.73
8.0.150.0030.00316.61
8.0.140.0000.00816.63
8.0.130.0030.00313.48
8.0.120.0070.00016.68
8.0.110.0040.00416.65
8.0.100.0080.00016.83
8.0.90.0000.00716.72
8.0.80.0080.00816.71
8.0.70.0040.00416.57
8.0.60.0070.00016.66
8.0.50.0000.00716.75
8.0.30.0080.01117.09
8.0.20.0110.00817.40
8.0.10.0040.00416.79
8.0.00.0090.00916.53
7.4.330.0070.01016.94
7.4.320.0060.00016.43
7.4.300.0030.00316.48
7.4.290.0030.00716.53
7.4.280.0070.00016.38
7.4.270.0000.00716.45
7.4.260.0070.00016.42
7.4.250.0040.00316.45
7.4.240.0060.00316.40
7.4.230.0070.00016.30
7.4.220.0100.01016.58
7.4.210.0100.01016.38
7.4.200.0030.00316.20
7.4.160.0100.00916.45
7.4.150.0090.00917.40
7.4.140.0090.01017.86
7.4.130.0090.00916.48
7.4.120.0120.00616.48
7.4.110.0090.00916.59
7.4.100.0100.01316.36
7.4.90.0140.00316.34
7.4.80.0110.00919.39
7.4.70.0140.00316.31
7.4.60.0110.00816.35
7.4.50.0000.01416.45
7.4.40.0070.01016.48
7.4.30.0080.01116.51
7.4.00.0000.01415.00
7.3.330.0030.01016.93
7.3.320.0030.01017.00
7.3.310.0070.00016.24
7.3.300.0000.00716.17
7.3.290.0100.00616.15
7.3.280.0080.00916.12
7.3.270.0130.00617.40
7.3.260.0120.00816.27
7.3.250.0070.01316.22
7.3.240.0040.01316.33
7.3.230.0140.00316.55
7.3.210.0140.00316.41
7.3.200.0120.00916.13
7.3.190.0140.00316.39
7.3.180.0060.01016.22
7.3.170.0100.00616.23
7.3.160.0100.01016.45
7.3.00.0130.01720.69
7.2.330.0140.00316.50
7.2.320.0190.00416.35
7.2.310.0100.00716.61
7.2.300.0070.01016.47
7.2.290.0080.00816.45
7.2.130.0160.01020.60
7.2.120.0170.01420.91
7.2.110.0200.01321.14
7.2.100.0150.01520.64
7.2.90.0030.02320.98
7.2.80.0070.02421.13
7.2.70.0100.02020.85
7.2.60.0030.01920.98
7.2.50.0120.01220.95
7.2.40.0120.01921.14
7.2.30.0160.01621.00
7.2.20.0070.01720.91
7.2.10.0070.02420.75
7.2.00.0080.01522.13
7.1.250.0030.03319.80
7.1.240.0130.02619.98
7.1.230.0090.02519.94
7.1.220.0070.03419.96
7.1.210.0070.03419.96
7.1.200.0060.02219.89
7.1.190.0130.03019.88
7.1.180.0070.03120.04
7.1.170.0070.03019.81
7.1.160.0130.02519.72
7.1.150.0070.03019.56
7.1.140.0070.03119.73
7.1.130.0070.02919.71
7.1.120.0090.02819.79
7.1.110.0000.03619.94
7.1.100.0080.02321.14
7.1.90.0130.02919.76
7.1.80.0160.02219.87
7.1.70.0100.03520.34
7.1.60.0160.03229.71
7.1.50.0120.03029.47
7.1.40.0150.03429.33
7.1.30.0170.03029.38
7.1.20.0200.03929.21
7.1.10.0120.03120.29
7.1.00.0140.02820.36
7.0.330.0070.03119.63
7.0.320.0100.03119.57
7.0.310.0070.03419.55
7.0.300.0100.02619.50
7.0.290.0130.03019.63
7.0.280.0100.02319.50
7.0.270.0130.02619.40
7.0.260.0060.02919.47
7.0.250.0120.03019.60
7.0.240.0030.03219.34
7.0.230.0000.03619.39
7.0.220.0100.02719.36
7.0.210.0030.03019.25
7.0.200.0080.02520.45
7.0.190.0090.02420.26
7.0.180.0100.02619.98
7.0.170.0110.02420.07
7.0.160.0070.03620.03
7.0.150.0110.03420.10
7.0.140.0150.02620.11
7.0.130.0070.03920.23
7.0.120.0050.03820.16
7.0.110.0070.02819.97
7.0.100.0080.03620.10
7.0.90.0110.02720.01
7.0.80.0050.03320.07
7.0.70.0050.03219.96
7.0.60.0070.03419.82
7.0.50.0070.03520.02
7.0.40.0070.03417.26
7.0.30.0120.02917.19
7.0.20.0120.02617.20
7.0.10.0080.03117.28
7.0.00.0080.03117.18
5.6.380.0140.05521.85

preferences:
47.67 ms | 400 KiB | 5 Q