Forum Moderators: coopster

Message Too Old, No Replies

I need a PHP code part which generates all possible string combination

I need a PHP code part which generates all possible string combinations

         

senkum

10:25 am on Oct 3, 2005 (gmt 0)



hi

I need to know how to generate all possible string combinations like....
aa
ab
ac
bb
...
aaa
bbb
ccc
aba
aca
aab
aac
...

The number of characters will be dynamic. the above one is for 3 chars.

plsssssssssss tell me how can i generate this?

killroy

12:20 pm on Oct 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's easy with an iterative function call, but you will VERY quickly get MANY combinations. What will you use it for? Will you need the final list or will you just feed it into another process? You might be better off usign a call back as well.

Regards,
SN

senkum

5:09 am on Oct 4, 2005 (gmt 0)



I dont want the full list. the list should be generated dynamically. It will go to another process. I want that for checking the deleted/expired/onhold/redumption period ..... domains. Is there any other way to find it.

I will use that list as input to the whois Server. From the result given I can split them up into different categories, I think so, but I dont know whether will that do or not.

I need more help about this. Can u gimme plz.

currently Im checking this...
$ar1=array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9');
for($i=1; $i<=1; $i++)
{
for($j=$i;$j<count($ar1);$j++)
{
for($k=$j;$k<count($ar1);$k++)
{
print "<br>".$ar1[$i].$ar1[$j].$ar1[$k];
}
}
}

but this will generate strings of only 3 chars.

I also tried the following code

$j=0;
for($i='a'; $i<='zzz'; $i++)
{
print "$i<br>";
$j++;
if($i=="zzz")
{
exit;
}
}

But I think i have to do it with some recursive function.

Thanks in advance
senkum