RE: [PHP] random generator.
| From: | o dot cook at etoncollege dot org dot uk | Date: | Mon, 08 Jan 2001 17:03:06 +0000 |
| Subject: | RE: [PHP] random generator. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-33256@lists.php.net to get a copy of this message | ||
Try something like this:
$acceptable_chars =
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
for ($count = 1; $count <= 8; $count ++) {
$random_string .= $acceptable_chars[rand(0,
strlen($acceptable_chars))];
}
Ollie
> -----Original Message-----
> From: Larry Hotchkiss [mailto:lhotch@unicap.com]
> Sent: 08 January 2001 16:57
> To: 'PHP General List'
> Subject: [PHP] random generator.
>
>
> Does anyone have a simple little code snippet to
> generat a random string
> of chars? I am populating a mysql DB with some data and would like to
> populate a couple fields with some random strings about 8
> chars in length,
> alphachars only would be fine, case does not matter.
>
> ---------------------------------
> Larry Hotchkiss
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
>