...

View Full Version : Random 4-Characters



CSS
07-19-2007, 07:48 PM
What I'm looking for is...
a script that randomly generates 100 4-letter 'words' that can consist of any amount of letters and numbers (1 letter, 3 numbers; 2 letters, 2 numbers, etc.), with only the exception that each 'word' begins with a letter. I'm newer to scripting, and I need this script rather urgently, and I honestly think I'm not understanding how to get this done. If someone could post this script and I'd be able to look at it, it'd do a lot for me.

devinemke
07-19-2007, 08:00 PM
$numbers = range(0,9);
$letters = range('a','z');
$both = array_merge($numbers, $letters);

$string = $letters[array_rand($letters)];
$string .= $both[array_rand($both)];
$string .= $both[array_rand($both)];
$string .= $both[array_rand($both)];

echo $string;

CSS
07-19-2007, 09:14 PM
Thanks! It works as expected, but is there a way to display 100 per page-load, with breaks in between each? Such as:

cnsh
xj35
d38v
(... for +97)

rafiki
07-19-2007, 09:17 PM
tried this?

for($i = 0, $i < 100, $i++){
$string = $letters[array_rand($letters)];
$string .= $both[array_rand($both)];
$string .= $both[array_rand($both)];
$string .= $both[array_rand($both)];

echo $string;
}

Fumigator
07-19-2007, 09:18 PM
Here's an alternative for you:



$secretCode = chr(rand(97,122)) . chr(rand(48, 57)) . chr(rand(48, 57)) . chr(rand(48, 57));



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum