Jump to content

Random Alphanumeric generator


nonexistentera

Recommended Posts

Hello.

I am wondering how I can get the script below to produce a list of random alphanumeric strings that are less that 10 characters in length and contain all possible combinations.

Such as "a, b, c... aa,ab,ac" until it goes through the full list of available characters.


<?PHP

$length = 2;

$complete = 10;
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';

$charslength = strlen($chars);

$randomstring = '';
mysql_connect("localhost","tylerper_root","tperroux") or die("No connection");

while ($t < $length)
{
while ($i < $complete) {
$randomstring .= substr($chars, rand(0, $charslength - 1), 1);

mysql_query("  

INSERT INTO `tylerper_cookbook2`.`xl` (
`id` ,
`md5`
)
VALUES (
'', '$randomstring'
);

");
echo $randomstring. "
<br>
";

$i++;
}

$t++;
}
?>


It produces some what what I would like but not as repeatative for each string length.

 

0

01

018

0181

01817

01817T

01817TV

01817TVS

01817TVSN

01817TVSN5

It only does the length once then goes up, but I need it to do the length the number of times of how many characters there are eg. 26. and have it change instead of just adding another random letter/number.

 

Any help is much appreciated.

Thanks

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.