I have letters in a string, I would like in result get all possible sets of those letters and convert them to numbers, each set should use all numbers, each number can occur only once in a set. numbers automatically should increment until 9. and output all possible combinations
Hide Copy Code
<blockquote class="quote"><div class="op">Quote:</div>function pc_permute($items, $perms = array( )) {
if (empty($items)) {
// var_dump(join($perms));
echo join($perms) . "\n";
// var_dump(join($perms));
} else {
for ($i = count($items) - 1; $i >= 0; --$i) {
$newitems = $items;
var_dump($newitems);
$newperms = $perms;
var_dump($newperms);
list($foo) = array_splice($newitems, $i, 1);
array_unshift($newperms, $foo);
pc_permute($newitems,$newperms);//, $newperms);
}
}
}
pc_permute(array('1','2','3')); </blockquote>
Outup is
Quote:
123
213
132
312
231
321
I need to get all combinations plus incrementng till 9, for example if output is '333abc'
output would be
333012
333052
333654
333162
333458
and so on.. untill 789 because need to check for letters not to repeat.
0 Answer(s)