note 51948 added to function.mt-rand
| From: | nowhere at where dot net | Date: | Sat, 16 Apr 2005 09:46:32 +0000 |
| Subject: | note 51948 added to function.mt-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88082@lists.php.net to get a copy of this message | ||
Allows characters 0-9, a-z
Weighted (and tested) ok.
<?php
function generate_string ($length = 20)
{
$nps = "";
for($i=0;$i<$length;$i++)
{
$nps .= chr( (mt_rand(1, 36) <= 26) ? mt_rand(97, 122) : mt_rand(48, 57 ));
}
return $nps;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.mt-rand.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51948
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51948&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51948&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51948&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51948&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51948&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51948&report=yes
Search -- http://master.php.net/manage/user-notes.php