3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['a', 'b', 'c', 'd','e','f','g']; function combinations($array, $k) { if ($k === 0) { return [[]]; } if (count($array) === $k) { return [$array]; } if (count($array) < $k) { return []; } $results = []; list($firstElem, $restArray) = [array_slice($array, 0, 1), array_slice($array, 1)]; foreach (combinations($restArray, $k - 1) as $combination) { $results[] = array_merge($firstElem, $combination); } foreach (combinations($restArray, $k) as $combination) { $results[] = $combination; } return $results; } $combinations = array_map('implode', combinations($array, 2)); print_r($combinations); ?>

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.5.10.0110.00519.30
8.5.00.0150.00920.24
8.4.160.0110.01123.62
8.4.150.0020.00114.05
8.4.140.0030.00617.52
8.4.130.0090.01118.75
8.4.120.0120.00820.54
8.4.110.0060.00318.75
8.4.100.0070.00417.50
8.4.90.0090.01320.54
8.4.80.0050.00420.47
8.4.70.0140.00718.18
8.4.60.0090.01118.72
8.4.50.0100.00620.38
8.4.40.0100.01017.35
8.4.30.0090.01020.60
8.4.20.0150.00017.72
8.4.10.0130.00323.95
8.3.280.0110.01318.29
8.3.270.0130.00516.35
8.3.260.0120.00816.62
8.3.250.0110.00817.03
8.3.240.0130.00616.73
8.3.230.0140.00616.68
8.3.220.0130.00518.93
8.3.210.0110.00716.56
8.3.200.0080.00416.64
8.3.190.0090.01017.38
8.3.180.0100.00916.60
8.3.170.0130.00618.84
8.3.160.0090.00019.94
8.3.150.0070.01119.10
8.3.140.0030.00516.66
8.3.130.0140.00016.55
8.3.120.0040.01120.64
8.3.110.0050.00518.58
8.3.100.0000.00916.65
8.3.90.0150.00026.77
8.3.80.0030.00618.55
8.3.70.0080.00818.30
8.3.60.0110.00418.43
8.3.50.0070.01416.56
8.3.40.0070.00720.29
8.3.30.0070.00720.31
8.3.20.0070.00024.18
8.3.10.0040.00424.66
8.3.00.0000.00826.16
8.2.290.0110.00817.28
8.2.280.0150.00618.13
8.2.270.0040.00417.27
8.2.260.0060.00317.23
8.2.250.0050.00318.48
8.2.240.0160.00317.09
8.2.230.0040.00420.94
8.2.220.0090.00324.06
8.2.210.0070.01126.77
8.2.200.0100.00016.75
8.2.190.0180.00316.58
8.2.180.0120.00916.88
8.2.170.0150.00019.00
8.2.160.0030.01022.96
8.2.150.0120.00325.66
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0050.00319.68
8.2.110.0090.00021.05
8.2.100.0070.00419.32
8.2.90.0040.00419.59
8.2.80.0000.00820.50
8.2.70.0030.00619.35
8.2.60.0060.00319.35
8.2.50.0030.00619.19
8.2.40.0080.00319.48
8.2.30.0030.00619.36
8.2.20.0090.00019.17
8.2.10.0000.00819.25
8.2.00.0040.00419.35
8.1.330.0120.00721.84
8.1.320.0080.01115.93
8.1.310.0090.00916.70
8.1.300.0070.00415.93
8.1.290.0000.01030.84
8.1.280.0070.01425.92
8.1.270.0110.00424.66
8.1.260.0030.00626.35
8.1.250.0070.00028.09
8.1.240.0000.00922.05
8.1.230.0040.00820.98
8.1.220.0040.00417.74
8.1.210.0000.00818.97
8.1.200.0000.00818.89
8.1.190.0040.00419.01
8.1.180.0030.00618.88
8.1.170.0060.00319.01
8.1.160.0040.00419.13
8.1.150.0090.00019.26
8.1.140.0090.00019.26
8.1.130.0040.00419.13
8.1.120.0000.00919.25
8.1.110.0030.00619.25
8.1.100.0060.00319.13
8.1.90.0060.00319.13
8.1.80.0040.00419.25
8.1.70.0040.00419.13
8.1.60.0030.00519.26
8.1.50.0030.00519.25
8.1.40.0040.00419.38
8.1.30.0080.00019.26
8.1.20.0040.00419.38
8.1.10.0080.00019.25
8.1.00.0040.00419.13
8.0.300.0030.00620.27
8.0.290.0050.00318.49
8.0.280.0080.00018.61
8.0.270.0000.00818.62
8.0.260.0030.00618.49
8.0.250.0090.00018.56
8.0.240.0090.00018.62
8.0.230.0040.00418.60
8.0.220.0060.00318.49
8.0.210.0000.00818.49
8.0.200.0060.00318.53
8.0.190.0000.00818.62
8.0.180.0040.00418.62
8.0.170.0090.00018.62
8.0.160.0040.00418.62
8.0.150.0060.00318.61
8.0.140.0040.00418.38
8.0.130.0040.00418.62
8.0.120.0040.00418.62
8.0.110.0000.00818.61
8.0.100.0080.00018.34
8.0.90.0000.00918.49
8.0.80.0080.00018.62
8.0.70.0080.00018.61
8.0.60.0080.00018.61
8.0.50.0050.00318.49
8.0.30.0040.00418.62
8.0.20.0000.00818.62
8.0.10.0000.00818.62

preferences:
36.2 ms | 403 KiB | 5 Q