Jump to content

Making a Sequence


nuxy

Recommended Posts

Hello,

 

I'm trying to generate a listing of just random letters.

I don't quite know how to explain this but, the output should be like this.

a
b
..
z
ab
..
az
ba
..
bz
..
zzzzzzzzzzzz

Now here comes the second part.

I would like to include numbers within the random letters, and a hypon.

I'm trying to make this for a script that will list domain names.

Examples:

d0main
3xample
google
..

 

Because the internet won't allow me to simply list all the domain names there is(only com, net, org), I'll have to do this.

So var I can only make weird unidentified figures.

 

Can anyone assist me with this?

Link to comment
Share on other sites

I forgot to give my current script.

$chars = 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','0','-');
$num = 0;
while(strlen($string) != count($chars)) {
    $string .= $chars[$num];
	$num++;
    echo $string . '<br>';
}

It works, but only for one sequence of "a", and also not with numbers within the words.

Example:

a
ab
abc
abcd
abcde
abcdef
abcdefg
abcdefgh
abcdefghi
abcdefghij
abcdefghijk
abcdefghijkl
abcdefghijklm
abcdefghijklmn
abcdefghijklmno
abcdefghijklmnop
abcdefghijklmnopq
abcdefghijklmnopqr
abcdefghijklmnopqrs
abcdefghijklmnopqrst
abcdefghijklmnopqrstu
abcdefghijklmnopqrstuv
abcdefghijklmnopqrstuvw
abcdefghijklmnopqrstuvwx
abcdefghijklmnopqrstuvwxy
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz0
abcdefghijklmnopqrstuvwxyz01
abcdefghijklmnopqrstuvwxyz012
abcdefghijklmnopqrstuvwxyz0123
abcdefghijklmnopqrstuvwxyz01234
abcdefghijklmnopqrstuvwxyz012345
abcdefghijklmnopqrstuvwxyz0123456
abcdefghijklmnopqrstuvwxyz01234567
abcdefghijklmnopqrstuvwxyz012345678
abcdefghijklmnopqrstuvwxyz0123456789
abcdefghijklmnopqrstuvwxyz01234567890
abcdefghijklmnopqrstuvwxyz01234567890-

 

Link to comment
Share on other sites

I think I understand what you're making - generating every combination of characters of x length.

 

I wrote a program to do this in VB a few years ago and was amazed at how long this took when I got to 6 letters or more. Trying something like this in PHP I believe would eventually time out and fail - maybe someone else could shed some light on this?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.