Posted by kanka on 11/12/96 11:43
Here is my problem,
I have a string like $numbers="12345";
i wanna find out all possible (unique) combinations of each subs.
e.g. 1 - 2 - 3 - 4 - 5 - 12 - 13 - 14 - 15 - 23 - 24 - ..... - 234 -
245 - .... - 12345
but not 11 - 22 - 21 - 32 - 321....
here is the function that i wrote not returns 13 - 14 - 15 or 24 - 25
$numbers="12345";
$total=strlen($numbers);
for ($j=0; $j< $total; $j++) {
for ($k=0; $k< ($total-$j); $k++) {
$c[]=substr($numbers, $k, $j+1);
}
}
Navigation:
[Reply to this message]
|