note 11935 deleted from function.rand.php by philip
| From: | philip@php.net | Date: | Sun, 26 Aug 2001 11:06:59 +0000 |
| Subject: | note 11935 deleted from function.rand.php by philip | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17160@lists.php.net to get a copy of this message | ||
Hi && How are you gentleman ? :)
Same as function above but without substr function
(no need to use functions for everything):
function rand_string ($pass_len = 10)
{
$allchar = "abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLNMOPQRSTUVWXYZ0123456789";
mt_srand ((double) microtime() * 1000000);
for ($i = 0, $str = "", $sz = strlen($allchar); $i < $pass_len; ++$i)
$str .= $allchar[mt_rand(0, $sz)];
return ($str);
}