PHP 4.0 Bug #9758: Is there any way that you can create a random letter from A-Z?
| From: | brad at simplysmarter dot org | Date: | Wed, 14 Mar 2001 22:41:46 +0000 |
| Subject: | PHP 4.0 Bug #9758: Is there any way that you can create a random letter from A-Z? | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-48953@lists.php.net to get a copy of this message | ||
From: brad@simplysmarter.org
Operating system: Unix
PHP version: 4.0.4pl1
PHP Bug Type: Feature/Change Request
Bug description: Is there any way that you can create a random letter from A-Z?
I would like to be able to create a random letter from A-Z for a member login authorization code. I
would like to have a 7 digit number ie: A543BC21 so that they can create a username and password. I
know how to randomize a number (ie: mt_rand( 0, 9 );) but how can I randomize letters? I tried
using mt_rand( "A", "Z" ) but as I expected, it gave me an "Invalid
Range" error. I could do this:
<?
$letter = mt_rand( 1, 36 );
if( $letter == "1" )
{
$letter = "A";
}
//etc. like this for A-Z
?>
but it would be exceptionally messy and way too long. Is there any other way to do it? If it
doesn't exist, can you add this to the next version of PHP?
Thanks so much!
Brad Taylor
Senior Web Developer
BradCom Industries LTD
www.simplysmarter.org
--
Edit Bug report at: http://bugs.php.net/?id=9758&edit=1