3v4l.org

run code in 300+ PHP versions simultaneously
<?php $vendors = ["Amazon", "Newegg", "Frys"]; $products = ['a', 'b']; $combinations = array(); // Algorithm to generate all combinations of a specific size from an array of possible values function sampling($chars, $size, $combinations = array()) { # if it's the first iteration, the first set # of combinations is the same as the set of characters if (empty($combinations)) { $combinations = $chars; } # we're done if we're at size 1 if ($size == 1) { return $combinations; } # initialise array to put new values in $new_combinations = array(); # loop through existing combinations and character set to create strings foreach ($combinations as $combination) { foreach ($chars as $char) { $new_combinations[] = $combination . $char; } } # call same function again for the next iteration return sampling($chars, $size - 1, $new_combinations); } // Build vendor combinations as a function of the number of products. Example with 5 products: // ['Amazon', 'Amazon', 'Amazon', 'Newegg', 'Newegg'] $combinations = sampling($vendors, count($products)); foreach ($combinations as $key => $combination) { // Calculate the total price var_dump($combination); }

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.70.0130.00616.75
8.3.60.0160.00318.41
8.3.50.0130.00521.27
8.3.40.0100.00718.84
8.3.30.0030.01220.20
8.3.20.0000.00720.33
8.3.10.0040.00422.04
8.3.00.0000.00822.52
8.2.180.0040.01116.63
8.2.170.0080.00522.96
8.2.160.0100.00322.22
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0070.01026.16
8.2.120.0070.00020.93
8.2.110.0110.00021.04
8.2.100.0090.00317.91
8.2.90.0000.00819.31
8.2.80.0030.00617.97
8.2.70.0060.00317.63
8.2.60.0050.00317.63
8.2.50.0040.00417.55
8.2.40.0050.00318.18
8.2.30.0000.00718.05
8.2.20.0040.00417.68
8.2.10.0000.00717.70
8.2.00.0040.00717.80
8.1.280.0140.00025.92
8.1.270.0080.00023.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00022.25
8.1.230.0040.00821.02
8.1.220.0040.00417.79
8.1.210.0040.00419.94
8.1.200.0040.00417.52
8.1.190.0040.00417.22
8.1.180.0040.00418.10
8.1.170.0000.00818.49
8.1.160.0000.00718.98
8.1.150.0070.00018.64
8.1.140.0040.00417.46
8.1.130.0000.00917.84
8.1.120.0050.00217.37
8.1.110.0040.00417.52
8.1.100.0070.00017.46
8.1.90.0040.00417.52
8.1.80.0000.00717.39
8.1.70.0000.00717.47
8.1.60.0060.00317.46
8.1.50.0000.00717.49
8.1.40.0000.00817.50
8.1.30.0020.00517.60
8.1.20.0060.00317.64
8.1.10.0030.00617.49
8.1.00.0070.00017.53
8.0.300.0070.00320.01
8.0.290.0040.00416.63
8.0.280.0030.00318.46
8.0.270.0070.00017.24
8.0.260.0030.00316.77
8.0.250.0070.00016.97
8.0.240.0040.00416.87
8.0.230.0000.00716.84
8.0.220.0080.00016.88
8.0.210.0000.00716.97
8.0.200.0000.00816.99
8.0.190.0040.00416.94
8.0.180.0030.00516.90
8.0.170.0050.00316.96
8.0.160.0000.00717.00
8.0.150.0000.00716.81
8.0.140.0030.00516.93
8.0.130.0030.00313.33
8.0.120.0030.00516.77
8.0.110.0000.00816.91
8.0.100.0030.00516.80
8.0.90.0040.00416.95
8.0.80.0040.01216.90
8.0.70.0000.00716.80
8.0.60.0020.00516.79
8.0.50.0050.00316.92
8.0.30.0080.01017.24
8.0.20.0150.00517.40
8.0.10.0040.00416.93
8.0.00.0140.01016.81
7.4.330.0050.00315.00
7.4.320.0030.00316.52
7.4.300.0030.00316.52
7.4.290.0030.00616.51
7.4.280.0070.00016.50
7.4.270.0030.00316.54
7.4.260.0040.00413.36
7.4.250.0000.00716.57
7.4.240.0020.00516.57
7.4.230.0000.00716.55
7.4.220.0100.00916.69
7.4.210.0080.00916.64
7.4.200.0030.00316.32
7.4.190.0040.00416.52
7.4.160.0120.00416.41
7.4.150.0060.01217.40
7.4.140.0150.00717.86
7.4.130.0110.00616.54
7.4.120.0130.00716.62
7.4.110.0140.00316.50
7.4.100.0060.02016.58
7.4.90.0140.00416.35
7.4.80.0100.00719.39
7.4.70.0110.00616.54
7.4.60.0160.00716.53
7.4.50.0030.00616.63
7.4.40.0110.00322.77
7.4.30.0070.01016.55
7.4.00.0100.00714.99
7.3.330.0000.00513.20
7.3.320.0030.00313.18
7.3.310.0000.00816.40
7.3.300.0000.00616.27
7.3.290.0090.00616.31
7.3.280.0110.00816.37
7.3.270.0130.00617.40
7.3.260.0040.01516.47
7.3.250.0120.00616.46
7.3.240.0060.01116.36
7.3.230.0160.00716.71
7.3.210.0110.00816.52
7.3.200.0030.01319.39
7.3.190.0140.00416.57
7.3.180.0030.01816.55
7.3.170.0090.00616.63
7.3.160.0130.00416.65
7.3.120.0090.00615.02
7.3.10.0070.00316.76
7.3.00.0070.00716.45
7.2.330.0090.00916.74
7.2.320.0090.01616.72
7.2.310.0110.00616.70
7.2.300.0140.00316.53
7.2.290.0090.00916.58
7.2.130.0100.00317.14
7.2.120.0040.01117.01
7.2.110.0060.00916.69
7.2.100.0090.00317.14
7.2.90.0060.00316.93
7.2.80.0080.00416.80
7.2.70.0060.00317.03
7.2.60.0050.01016.93
7.2.50.0020.01116.84
7.2.40.0090.00316.88
7.2.30.0070.00316.99
7.2.20.0000.01417.06
7.2.10.0090.00017.09
7.2.00.0100.00316.76
7.1.250.0110.00415.96
7.1.200.0040.00815.58
7.1.70.0040.00416.95
7.1.60.0090.01219.32
7.1.50.0100.01016.63
7.1.00.0030.06322.31
7.0.200.0040.00416.51
7.0.140.0030.07322.17
7.0.90.0570.06020.02
7.0.80.0700.06019.95
7.0.70.0530.08719.96
7.0.60.0670.05020.08
7.0.50.0270.05020.38
7.0.40.0100.03720.20
7.0.30.0100.04720.04
7.0.20.0070.08020.10
7.0.10.0070.05720.03
7.0.00.0200.07720.14
5.6.280.0100.06720.91
5.6.230.0070.07720.68
5.6.220.0000.08720.58
5.6.210.0100.08020.57
5.6.200.0030.06721.08
5.6.190.0200.03721.03
5.6.180.0000.08321.09
5.6.170.0030.08720.94
5.6.160.0030.09021.10
5.6.150.0100.07721.05
5.6.140.0030.06020.96
5.6.130.0070.09020.95
5.6.120.0130.07021.09
5.6.110.0100.08320.93
5.6.100.0100.07321.03
5.6.90.0200.07721.09
5.6.80.0070.06320.52
5.6.70.0030.04320.40
5.6.60.0030.04720.49
5.6.50.0030.05020.35
5.6.40.0070.08020.46
5.6.30.0100.03320.41
5.6.20.0100.07720.53
5.6.10.0170.07320.38
5.6.00.0030.08320.39
5.5.370.0030.06320.36
5.5.360.0170.07020.39
5.5.350.0070.06020.45
5.5.340.0100.08320.88
5.5.330.0100.07720.77
5.5.320.0230.06020.93
5.5.310.0130.08020.77
5.5.300.0100.08320.87
5.5.290.0000.09020.78
5.5.280.0130.04720.64
5.5.270.0070.08020.89
5.5.260.0000.05720.79
5.5.250.0030.05720.62
5.5.240.0000.09020.31
5.5.230.0070.08020.18
5.5.220.0070.07320.20
5.5.210.0070.04320.26
5.5.200.0170.06320.13
5.5.190.0070.08720.19
5.5.180.0070.08020.14
5.5.160.0070.08320.09
5.5.150.0030.07320.25
5.5.140.0200.06020.22
5.5.130.0100.07720.25
5.5.120.0130.07320.25
5.5.110.0070.05320.26
5.5.100.0030.04320.16
5.5.90.0070.06720.17
5.5.80.0100.07319.96
5.5.70.0070.06319.92
5.5.60.0070.07020.02
5.5.50.0130.07020.16
5.5.40.0030.05720.10
5.5.30.0100.07720.08
5.5.20.0100.06320.08
5.5.10.0070.07319.96
5.5.00.0070.04720.11
5.4.450.0070.05019.43
5.4.440.0030.08019.41
5.4.430.0130.05719.48
5.4.420.0070.07319.35
5.4.410.0070.07019.14
5.4.400.0130.07318.85
5.4.390.0130.07018.94
5.4.380.0070.07018.92
5.4.370.0070.04319.16
5.4.360.0130.07019.16
5.4.350.0070.04719.14
5.4.340.0130.07318.85
5.4.320.0030.08019.03
5.4.310.0030.04319.20
5.4.300.0070.05018.91
5.4.290.0030.06718.85
5.4.280.0100.07319.09
5.4.270.0070.07718.85
5.4.260.0070.04319.23
5.4.250.0030.07719.02
5.4.240.0070.04718.94
5.4.230.0100.07319.16
5.4.220.0100.07318.84
5.4.210.0170.06718.94
5.4.200.0070.04719.12
5.4.190.0070.05019.03
5.4.180.0100.07018.89
5.4.170.0070.08018.89
5.4.160.0270.05319.18
5.4.150.0070.07319.21
5.4.140.0070.05016.41
5.4.130.0070.05316.50
5.4.120.0100.06016.44
5.4.110.0070.05716.47
5.4.100.0070.05016.34
5.4.90.0070.07716.36
5.4.80.0100.07016.45
5.4.70.0170.03316.46
5.4.60.0030.07716.25
5.4.50.0030.07016.41
5.4.40.0030.07316.46
5.4.30.0100.07316.29
5.4.20.0070.07716.35
5.4.10.0030.06016.35
5.4.00.0170.06015.78
5.3.290.0130.07314.52
5.3.280.0000.05014.46
5.3.270.0100.03314.48
5.3.260.0030.07714.60
5.3.250.0030.07314.43
5.3.240.0130.07014.52
5.3.230.0030.07314.42
5.3.220.0100.07714.43
5.3.210.0100.07014.40
5.3.200.0130.06314.40
5.3.190.0070.07314.51
5.3.180.0100.07014.38
5.3.170.0100.07314.41
5.3.160.0100.07314.43
5.3.150.0100.06714.50
5.3.140.0070.06314.46
5.3.130.0070.06314.53
5.3.120.0130.07014.37
5.3.110.0070.06714.50
5.3.100.0100.05713.98
5.3.90.0030.07313.96
5.3.80.0030.08013.92
5.3.70.0130.06313.99
5.3.60.0070.04013.95
5.3.50.0000.04713.94
5.3.40.0070.04013.91
5.3.30.0070.07013.77
5.3.20.0070.07313.67
5.3.10.0130.06313.66
5.3.00.0070.07013.66
5.2.170.0000.06713.66
5.2.160.0030.06713.66
5.2.150.0030.06713.66
5.2.140.0070.06313.66
5.2.130.0130.05013.66
5.2.120.0000.04713.66
5.2.110.0070.06013.66
5.2.100.0030.03313.66
5.2.90.0070.06013.66
5.2.80.0030.05013.66
5.2.70.0030.06313.66
5.2.60.0030.04713.66
5.2.50.0100.04313.66
5.2.40.0030.05313.66
5.2.30.0000.04313.66
5.2.20.0030.06013.66
5.2.10.0000.04313.66
5.2.00.0070.05013.66
5.1.60.0000.04313.66
5.1.50.0070.04713.66
5.1.40.0000.06013.66
5.1.30.0070.05013.66
5.1.20.0070.05713.66
5.1.10.0030.05713.66
5.1.00.0170.03313.66
5.0.50.0000.05013.66
5.0.40.0000.04713.66
5.0.30.0070.05013.66
5.0.20.0030.04313.66
5.0.10.0070.04013.66
5.0.00.0070.06313.66
4.4.90.0030.03713.66
4.4.80.0030.03313.66
4.4.70.0000.03313.66
4.4.60.0070.03013.66
4.4.50.0000.03313.66
4.4.40.0000.05313.66
4.4.30.0000.03713.66
4.4.20.0000.03013.66
4.4.10.0000.03713.66
4.4.00.0030.04713.66
4.3.110.0070.03013.66
4.3.100.0000.02013.66
4.3.90.0000.02713.66
4.3.80.0030.05713.66
4.3.70.0030.03013.66
4.3.60.0030.03013.66
4.3.50.0030.02713.66
4.3.40.0070.04713.66
4.3.30.0030.02013.66
4.3.20.0000.02313.66
4.3.10.0000.01713.66
4.3.00.0000.01713.66

preferences:
57.1 ms | 401 KiB | 5 Q