3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Returns the total number of $count-length strings generatable from $letters. function getPermCount($letters, $count) { $result = 1; // k characters from a set of n has n!/(n-k)! possible combinations for($i = strlen($letters) - $count + 1; $i <= strlen($letters); $i++) { $result *= $i; } return $result; } // Decodes $index to a $count-length string from $letters, no repeat chars. function getPerm($letters, $count, $index) { $result = ''; for($i = 0; $i < $count; $i++) { $pos = $index % strlen($letters); $result .= ",".$letters[$pos]; $index = ($index-$pos)/strlen($letters); $letters = substr($letters, 0, $pos) . substr($letters, $pos+1); } return trim($result, ","); } $abc = array(); $cars=array("a","b","c"); sort($cars); $abc[] = $cars; $cars=array("a","c","b"); sort($cars); $abc[] = $cars; print_r(array_unique($abc, SORT_REGULAR)); $letters = 'abc'; $r = array(); //echo '1 letters from 4: '; for($i = 0; $i < getPermCount($letters, 1); $i++) $r[] = getPerm($letters, 1, $i); //echo '2 letters from 4: '; for($i = 0; $i < getPermCount($letters, 2); $i++) $r[] = getPerm($letters, 2, $i); //echo ' 3 letters from 4: '; for($i = 0; $i < getPermCount($letters, 3); $i++) $r[] = getPerm($letters, 3, $i); print_r($r);

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.0090.01218.43
8.3.50.0140.00721.21
8.3.40.0110.00718.84
8.3.30.0060.00920.17
8.3.20.0080.00018.96
8.3.10.0080.00021.23
8.3.00.0000.00822.16
8.2.180.0160.00316.63
8.2.170.0100.01022.96
8.2.160.0070.01020.47
8.2.150.0000.00924.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0000.00719.85
8.2.110.0050.00322.07
8.2.100.0040.00817.72
8.2.90.0040.00419.22
8.2.80.0000.00819.25
8.2.70.0050.00317.25
8.2.60.0080.00018.03
8.2.50.0000.00818.07
8.2.40.0080.00019.88
8.2.30.0030.00519.53
8.2.20.0030.00517.82
8.2.10.0030.00617.84
8.2.00.0040.00417.65
8.1.280.0090.00625.92
8.1.270.0080.00023.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00322.61
8.1.230.0050.00520.85
8.1.220.0030.00718.77
8.1.210.0030.00618.78
8.1.200.0050.00517.25
8.1.190.0050.00317.41
8.1.180.0000.00918.10
8.1.170.0050.00318.43
8.1.160.0000.00718.92
8.1.150.0040.00418.71
8.1.140.0040.00417.53
8.1.130.0070.00017.85
8.1.120.0040.00417.48
8.1.110.0040.00417.46
8.1.100.0050.00317.43
8.1.90.0030.00417.48
8.1.80.0000.00717.38
8.1.70.0000.00717.39
8.1.60.0060.00317.62
8.1.50.0030.00517.50
8.1.40.0040.00417.56
8.1.30.0000.00917.69
8.1.20.0040.00417.66
8.1.10.0030.00617.55
8.1.00.0040.00417.50
8.0.300.0070.00019.88
8.0.290.0000.00817.17
8.0.280.0080.00018.39
8.0.270.0080.00017.29
8.0.260.0000.00716.76
8.0.250.0000.00716.86
8.0.240.0000.00817.02
8.0.230.0040.00416.89
8.0.220.0050.00316.89
8.0.210.0030.00316.87
8.0.200.0040.00416.86
8.0.190.0030.00516.88
8.0.180.0070.00016.96
8.0.170.0030.00516.81
8.0.160.0040.00416.82
8.0.150.0000.00816.83
8.0.140.0080.00016.79
8.0.130.0030.00313.35
8.0.120.0030.00516.88
8.0.110.0040.00416.96
8.0.100.0040.00416.98
8.0.90.0070.00016.92
8.0.80.0090.00616.95
8.0.70.0020.00516.79
8.0.60.0000.00816.75
8.0.50.0070.00016.75
8.0.30.0100.01117.21
8.0.20.0080.01517.40
8.0.10.0040.00417.11
8.0.00.0090.00916.79
7.4.330.0020.00216.83
7.4.320.0030.00316.43
7.4.300.0030.00316.55
7.4.290.0030.00316.52
7.4.280.0000.00716.48
7.4.270.0000.00716.44
7.4.260.0030.00313.34
7.4.250.0000.00816.52
7.4.240.0000.00716.52
7.4.230.0000.00716.64
7.4.220.0140.00916.38
7.4.210.0090.00816.54
7.4.200.0030.00316.38
7.4.190.0070.00016.69
7.4.160.0060.01016.65
7.4.150.0130.00417.40
7.4.140.0080.01117.86
7.4.130.0130.00316.63
7.4.120.0110.00616.62
7.4.110.0030.02016.61
7.4.100.0040.01316.45
7.4.90.0120.00616.69
7.4.80.0120.00619.39
7.4.70.0090.00916.68
7.4.60.0000.01616.63
7.4.50.0050.00316.53
7.4.40.0070.00722.77
7.4.30.0150.00816.41
7.4.00.0100.01014.68
7.3.330.0030.00213.20
7.3.320.0030.00313.32
7.3.310.0070.00016.22
7.3.300.0060.00316.28
7.3.290.0060.00916.39
7.3.280.0080.00916.43
7.3.270.0070.01117.40
7.3.260.0120.00818.24
7.3.250.0120.00616.36
7.3.240.0110.00516.40
7.3.230.0090.01616.64
7.3.210.0060.01216.46
7.3.200.0150.00719.39
7.3.190.0110.00716.39
7.3.180.0030.01316.46
7.3.170.0060.01616.41
7.3.160.0150.00016.70
7.3.120.0130.00714.79
7.3.110.0060.01215.00
7.3.100.0090.00615.09
7.3.90.0000.00915.01
7.3.80.0070.00714.99
7.3.70.0030.01014.91
7.3.60.0080.00815.01
7.3.50.0130.00715.01
7.3.40.0030.01614.65
7.3.30.0030.00914.77
7.3.20.0110.00316.54
7.3.10.0030.00616.80
7.3.00.0040.01416.73
7.2.330.0090.00916.80
7.2.320.0110.00616.80
7.2.310.0080.00916.47
7.2.300.0070.01016.52
7.2.290.0130.00316.79
7.2.250.0070.01015.29
7.2.240.0000.01914.86
7.2.230.0110.00715.06
7.2.220.0030.01314.92
7.2.210.0090.00615.15
7.2.200.0040.01214.81
7.2.190.0100.00014.90
7.2.180.0070.01315.06
7.2.170.0110.00814.86
7.2.160.0070.00714.82
7.2.150.0070.01016.98
7.2.140.0070.00717.15
7.2.130.0100.00717.11
7.2.120.0040.01816.98
7.2.110.0050.00517.02
7.2.100.0060.00616.79
7.2.90.0080.00816.98
7.2.80.0060.00916.91
7.2.70.0030.01217.09
7.2.60.0070.01016.85
7.2.50.0100.00716.68
7.2.40.0050.00517.04
7.2.30.0070.00717.01
7.2.20.0030.00716.95
7.2.10.0070.00716.70
7.2.00.0030.01017.02
7.1.330.0000.01415.99
7.1.320.0070.00715.82
7.1.310.0070.00715.75
7.1.300.0070.00716.03
7.1.290.0060.01315.60
7.1.280.0040.01415.79
7.1.270.0000.01115.82
7.1.260.0070.00715.92
7.1.250.0130.00715.92
7.1.100.0080.00818.07
7.1.70.0060.00317.23
7.1.60.0170.00719.24
7.1.50.0090.00316.96
7.1.00.0030.06322.31
7.0.200.0000.00916.88
7.0.140.0070.06322.00
7.0.100.0130.06019.90
7.0.90.0170.08019.91
7.0.80.0070.04319.88
7.0.70.0170.06719.98
7.0.60.0100.04320.07
7.0.50.0300.08320.32
7.0.40.0070.08320.15
7.0.30.0130.08320.05
7.0.20.0130.08020.17
7.0.10.0100.08020.13
7.0.00.0200.07319.99
5.6.280.0030.07320.82
5.6.250.0100.08020.61
5.6.240.0070.05020.52
5.6.230.0030.09020.68
5.6.220.0100.07320.75
5.6.210.0170.06320.69
5.6.200.0100.04020.98
5.6.190.0170.08021.05
5.6.180.0030.04721.06
5.6.170.0130.06020.96
5.6.160.0070.06021.09
5.6.150.0130.08321.11
5.6.140.0030.07721.08
5.6.130.0170.07321.03
5.6.120.0100.08021.05
5.6.110.0030.06721.04
5.6.100.0130.07021.08
5.6.90.0200.06321.04
5.6.80.0070.08020.48
5.6.70.0030.06720.50
5.6.60.0130.07320.33
5.6.50.0000.08720.54
5.6.40.0100.07320.50
5.6.30.0000.05720.45
5.6.20.0200.06320.38
5.6.10.0170.03720.37
5.6.00.0170.07720.37
5.5.380.0100.05320.46
5.5.370.0000.08020.43
5.5.360.0170.06720.36
5.5.350.0100.05020.43
5.5.340.0200.07020.81
5.5.330.0000.09720.66
5.5.320.0070.07320.91
5.5.310.0100.07720.88
5.5.300.0070.08320.74
5.5.290.0030.05020.91
5.5.280.0100.07720.84
5.5.270.0230.07020.81
5.5.260.0130.08320.79
5.5.250.0070.08720.68
5.5.240.0130.05320.20
5.5.230.0130.08020.31
5.5.220.0030.08020.26
5.5.210.0130.08320.22
5.5.200.0070.08020.24
5.5.190.0130.05720.27
5.5.180.0170.07320.23
5.5.160.0000.08020.20
5.5.150.0100.07020.25
5.5.140.0100.07320.13
5.5.130.0100.07320.00
5.5.120.0070.04720.22
5.5.110.0030.05720.22
5.5.100.0070.08020.18
5.5.90.0130.04019.91
5.5.80.0100.07720.17
5.5.70.0030.05020.15
5.5.60.0170.06320.09
5.5.50.0200.06320.16
5.5.40.0100.06720.16
5.5.30.0200.06720.09
5.5.20.0100.08719.94
5.5.10.0130.06720.03
5.5.00.0070.04720.04
5.4.450.0030.08319.50
5.4.440.0030.07719.56
5.4.430.0070.08319.21
5.4.420.0030.05319.20
5.4.410.0130.07019.36
5.4.400.0170.04719.19
5.4.390.0070.07019.18
5.4.380.0000.05319.16
5.4.370.0100.07319.13
5.4.360.0130.07719.05
5.4.350.0130.03718.85
5.4.340.0100.05019.03
5.4.320.0030.05319.04
5.4.310.0230.05719.09
5.4.300.0070.07719.03
5.4.290.0130.07019.23
5.4.280.0070.03719.03
5.4.270.0130.07019.09
5.4.260.0070.07719.02
5.4.250.0030.07319.05
5.4.240.0170.06318.89
5.4.230.0070.07319.04
5.4.220.0030.05019.03
5.4.210.0170.06718.84
5.4.200.0030.07319.17
5.4.190.0070.07019.03
5.4.180.0070.07018.84
5.4.170.0130.05018.89
5.4.160.0070.06018.86
5.4.150.0070.06719.01
5.4.140.0070.07016.51
5.4.130.0070.07316.38
5.4.120.0100.07016.50
5.4.110.0000.05016.32
5.4.100.0100.04016.56
5.4.90.0070.04016.56
5.4.80.0130.03716.53
5.4.70.0000.08316.36
5.4.60.0170.07316.42
5.4.50.0070.05716.29
5.4.40.0100.06716.42
5.4.30.0130.03316.31
5.4.20.0030.03716.47
5.4.10.0070.06316.32
5.4.00.0030.04315.78
5.3.290.0030.07314.62
5.3.280.0030.08014.60
5.3.270.0070.09014.59
5.3.260.0130.07314.57
5.3.250.0070.05014.68
5.3.240.0130.06714.63
5.3.230.0030.07314.54
5.3.220.0070.07714.61
5.3.210.0030.07714.57
5.3.200.0100.08014.73
5.3.190.0030.08314.72
5.3.180.0070.07314.63
5.3.170.0130.07314.59
5.3.160.0100.07714.50
5.3.150.0030.04714.67
5.3.140.0100.08014.59
5.3.130.0030.08314.50
5.3.120.0130.04014.68
5.3.110.0130.05714.49
5.3.100.0070.06014.04
5.3.90.0100.07314.16
5.3.80.0030.04313.93
5.3.70.0070.06014.02
5.3.60.0030.06714.04
5.3.50.0030.04014.00
5.3.40.0030.07713.98
5.3.30.0100.07014.04
5.3.20.0070.04713.67
5.3.10.0030.04313.67
5.3.00.0130.05713.75
5.2.170.0030.06313.67
5.2.160.0000.07013.67
5.2.150.0130.05713.67
5.2.140.0030.06713.67
5.2.130.0030.06013.67
5.2.120.0030.06313.67
5.2.110.0030.03713.67
5.2.100.0030.06313.67
5.2.90.0000.03313.67
5.2.80.0030.06713.67
5.2.70.0100.05013.67
5.2.60.0070.03313.67
5.2.50.0000.06313.67
5.2.40.0130.06013.67
5.2.30.0100.05313.67
5.2.20.0070.05013.67
5.2.10.0030.03013.67
5.2.00.0030.03013.67
5.1.60.0030.02713.67
5.1.50.0030.05013.67
5.1.40.0000.04013.67
5.1.30.0100.05713.67
5.1.20.0070.03713.67
5.1.10.0030.05313.67
5.1.00.0100.04713.67
5.0.50.0030.03713.67
5.0.40.0000.04713.67
5.0.30.0070.06313.67
5.0.20.0070.03313.67
5.0.10.0070.03713.67
5.0.00.0070.06713.67
4.4.90.0030.03013.67
4.4.80.0000.02713.67
4.4.70.0100.02713.67
4.4.60.0070.03313.67
4.4.50.0030.02313.67
4.4.40.0030.04713.67
4.4.30.0070.03313.67
4.4.20.0070.01313.67
4.4.10.0000.03713.67
4.4.00.0000.05713.67
4.3.110.0000.03313.67
4.3.100.0100.02313.67
4.3.90.0030.03313.67
4.3.80.0100.04313.67
4.3.70.0030.03313.67
4.3.60.0030.02313.67
4.3.50.0000.02013.67
4.3.40.0030.02713.67
4.3.30.0030.03313.67
4.3.20.0030.02013.67
4.3.10.0030.02313.67
4.3.00.0000.03013.67

preferences:
69.67 ms | 401 KiB | 5 Q