RE: [PHP-GENERAL] Can someone help me with an array problem?
| From: | Chris Sano | Date: | Mon, 05 Jun 2000 06:10:27 +0000 |
| Subject: | RE: [PHP-GENERAL] Can someone help me with an array problem? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1019@lists.php.net to get a copy of this message | ||
rick is right, only need to seed the random generator once.
chris
-----Original Message-----
From: php3@developersdesk.com [mailto:php3@developersdesk.com]
Sent: Monday, June 05, 2000 2:35 AM
To: Brandt Everett; php-general@lists.php.net
Subject: Re: [PHP-GENERAL] Can someone help me with an array problem?
Addressed to: "Brandt Everett" <everett@bentonrea.com>
<php-general@lists.php.net>
** Reply to note from "Brandt Everett" <everett@bentonrea.com> Sun, 4 Jun
2000 20:18:11 -0700
>
> Here is a general random password generator I wrote. This might help
> you.
>
> function RandomPassword($length = "") { if( empty($length) ) $length
> = 8;
>
> $password = "";
>
> $possiblecharacter =
> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz234567890_"; //
> removed 1(one) l(letter) to avoid confusion
>
> for($index = 0; $index < $length; $index++) {
> srand((double)microtime()*1000000); $number = rand(0,
> strlen($possiblecharacter) -1); $password = $password .
> $possiblecharacter[$number]; }
>
> return $password;
I beleive you only need to call srand() once per program, so it should
be moved out of the for loop.
Rick Widmer
Internet Marketing Specialists
www.developersdesk.com
--
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