note 31018 deleted from function.mt-rand by bjori
| From: | bjori@php.net | Date: | Sun, 16 Apr 2006 12:24:29 +0000 |
| Subject: | note 31018 deleted from function.mt-rand by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-108253@lists.php.net to get a copy of this message | ||
Note Submitter: donald at design dot net
----
here's a REALLY simple random string generator, not as long and complicated as the others, but
the same in theory:
function randstr($length = 16) {
mt_srand((double)microtime()*10000);
for($i=0;$i<$length;$i++) {
$x = mt_rand(1,3);
$str .= (($x == 1) ? chr(mt_rand(48,57)) : (($x == 2) ? chr(mt_rand(65,90)) :
chr(mt_rand(97,122))));
}
return $str;
}