Re: Can someone help me with an array problem?
| From: | php3 at developersdesk dot com | Date: | Mon, 05 Jun 2000 06:35:11 +0000 |
| Subject: | Re: Can someone help me with an array problem? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-1017@lists.php.net to get a copy of this message | ||
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