note 31018 added to function.mt-rand
| From: | donald at rack1 dot php dot net | Date: | Mon, 07 Apr 2003 04:18:50 +0000 |
| Subject: | note 31018 added to function.mt-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46298@lists.php.net to get a copy of this message | ||
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;
}
--
http://www.php.net/manual/en/function.mt-rand.php
http://master.php.net/manage/user-notes.php?action=edit+31018
http://master.php.net/manage/user-notes.php?action=delete+31018
http://master.php.net/manage/user-notes.php?action=reject+31018