On Wed, 2004-02-25 at 11:25, [EMAIL PROTECTED] wrote:
> I'm trying to create a PHP sequential random character generator that will output to 
> a file database of some sort. The randomization needs to be using both capital 
> letters and numbers. I need to output like 2 million records. Can someone point me 
> in the right direction on how to do this?
> 
> I'm also looking to to this without letters as well.

Make an array containing the characters/numbers/whatever you want to be
selected at random then pick from it using a random integer generated
from mt_rand[1] and echo your selection.  If you have PHP < 4.2.0 you
will also need to use mt_srand[2].

$field = array('a','b');
$field_max = count($field) - 1;
echo $field[mt_rand(0, $field_max)];

[1] http://www.php.net/mt_rand
[2] http://www.php.net/mt_srand

-- 
Adam Bregenzer
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to