note 69409 deleted from function.chr by danbrown
| From: | danbrown@php.net | Date: | Wed, 15 Sep 2010 21:10:32 +0000 |
| Subject: | note 69409 deleted from function.chr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172595@lists.php.net to get a copy of this message | ||
Note Submitter: jdavid at skynet dot be
----
To elaborate on JasonLauDotBiz's piece of code and also schafer at robandger dot com:
for ($i = 0; $i < 10; $i++) {
$randnum = mt_rand(0,61);
if ($randnum < 10)
$randstr .= $randnum;
else if ($randnum < 36)
$randstr .= chr($randnum+55);
else
$randstr .= chr($randnum+61);
}
echo $randstr;
This will give you a 10 character string consisting of [A-Za-z0-9]. Usefull for passwords or other
random strings.