Random string
| From: | n e t b r a i n | Date: | Fri, 15 Sep 2000 08:16:42 +0000 |
| Subject: | Random string | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-16890@lists.php.net to get a copy of this message | ||
Hi,
I'm in trouble in order to implement a small function for a random
alphanumeric string of 8 charcters lenght (well, I mean: a password of 8
chars ...)
Reading the Wrox php book, I've founded this:
function random($lenght) {
$possibili="0123456789+-zxcvbnmlkjhgfdsapoiuytrewqZXCVBNMLKJHGFDSAPOIUYTREWQ
";
$stringa=" ";
while(strlen($stringa) < $lenght) {
$stringa .=substr($possibili, mt_rand(0, strlen($possibili) -1), 1);
}
echo($stringa);
}
random(8);
But the main problem is that it seem doesn't work ... infact it produce
often a php_time_out ...
Anyone could help me with suggestion or show me a small snippet of code in
order to create unique passwords of 8 chars?
Many thanks in advance.
max