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
https://forums.phpfreaks.com/topic/120128-random-alphanumeric-generator/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.