note 49608 added to function.rand
| From: | polmme at hotmail dot com | Date: | Wed, 02 Feb 2005 23:10:48 +0000 |
| Subject: | note 49608 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84398@lists.php.net to get a copy of this message | ||
Why not just like this....
<?
//author: polmme
$codelenght = 10;
while($newcode_length < $codelenght) {
$x=1;
$y=3;
$part = rand($x,$y);
if($part==1){$a=48;$b=57;} // Numbers
if($part==2){$a=65;$b=90;} // UpperCase
if($part==3){$a=97;$b=122;} // LowerCase
$code_part=chr(rand($a,$b));
$newcode_length = $newcode_length + 1;
$newcode = $newcode.$code_part;
}
echo $newcode;
?>
----
Manual Page -- http://www.php.net/manual/en/function.rand.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49608
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49608&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49608&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49608&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49608&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49608&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49608&report=yes
Search -- http://master.php.net/manage/user-notes.php