<?php
$products = [1, 2, 3, 4, 5];
$vendors = ["Amazon", "Newegg", "Frys"];
$combinations = array('');
function pc_permute($items, $perms = array()) {
if (empty($items)) {
echo join(' ', $perms);
//return $perms;
//array_push($combinations, $perms);
} else {
for ($i = count($items) - 1; $i >= 0; --$i) {
$newitems = $items;
$newperms = $perms;
list($foo) = array_splice($newitems, $i, 1);
array_unshift($newperms, $foo);
pc_permute($newitems, $newperms);
}
}
}
pc_permute($products);
var_dump($combinations);
- Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
- 1 2 3 4 52 1 3 4 51 3 2 4 53 1 2 4 52 3 1 4 53 2 1 4 51 2 4 3 52 1 4 3 51 4 2 3 54 1 2 3 52 4 1 3 54 2 1 3 51 3 4 2 53 1 4 2 51 4 3 2 54 1 3 2 53 4 1 2 54 3 1 2 52 3 4 1 53 2 4 1 52 4 3 1 54 2 3 1 53 4 2 1 54 3 2 1 51 2 3 5 42 1 3 5 41 3 2 5 43 1 2 5 42 3 1 5 43 2 1 5 41 2 5 3 42 1 5 3 41 5 2 3 45 1 2 3 42 5 1 3 45 2 1 3 41 3 5 2 43 1 5 2 41 5 3 2 45 1 3 2 43 5 1 2 45 3 1 2 42 3 5 1 43 2 5 1 42 5 3 1 45 2 3 1 43 5 2 1 45 3 2 1 41 2 4 5 32 1 4 5 31 4 2 5 34 1 2 5 32 4 1 5 34 2 1 5 31 2 5 4 32 1 5 4 31 5 2 4 35 1 2 4 32 5 1 4 35 2 1 4 31 4 5 2 34 1 5 2 31 5 4 2 35 1 4 2 34 5 1 2 35 4 1 2 32 4 5 1 34 2 5 1 32 5 4 1 35 2 4 1 34 5 2 1 35 4 2 1 31 3 4 5 23 1 4 5 21 4 3 5 24 1 3 5 23 4 1 5 24 3 1 5 21 3 5 4 23 1 5 4 21 5 3 4 25 1 3 4 23 5 1 4 25 3 1 4 21 4 5 3 24 1 5 3 21 5 4 3 25 1 4 3 24 5 1 3 25 4 1 3 23 4 5 1 24 3 5 1 23 5 4 1 25 3 4 1 24 5 3 1 25 4 3 1 22 3 4 5 13 2 4 5 12 4 3 5 14 2 3 5 13 4 2 5 14 3 2 5 12 3 5 4 13 2 5 4 12 5 3 4 15 2 3 4 13 5 2 4 15 3 2 4 12 4 5 3 14 2 5 3 12 5 4 3 15 2 4 3 14 5 2 3 15 4 2 3 13 4 5 2 14 3 5 2 13 5 4 2 15 3 4 2 14 5 3 2 15 4 3 2 1array(1) {
[0]=>
string(0) ""
}
- Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
- Parse error: syntax error, unexpected '[' in /in/kjWXP on line 3
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
- Parse error: parse error, unexpected '[' in /in/kjWXP on line 3
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/kjWXP on line 3
Process exited with code 255.
preferences:
323.72 ms | 401 KiB | 461 Q