note 100714 added to function.chr
| From: | b54b9 at m36u86n45i45m dot net | Date: | Mon, 01 Nov 2010 19:37:33 +0000 |
| Subject: | note 100714 added to function.chr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173677@lists.php.net to get a copy of this message | ||
chr can be used to generate random strings too
<?php
function getRandomString($length = 6)
{
$map = Array("0" => Array("min" => 48, "max" => 57),
"1" => Array("min" => 65, "max" => 90), "2" =>
Array("min" => 97, "max" => 122));
$randString = "";
$current = 0;
for ($i = 0; $i < $length; $i++) {
$r = $map[mt_rand(0, 2)];
$randString .= chr(mt_rand($r["min"], $r["max"]));
}
return $randString;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 180.234.45.187
----
Manual Page -- http://www.php.net/manual/en/function.chr.php
Edit -- https://master.php.net/note/edit/100714
Del: integrated -- https://master.php.net/note/delete/100714/integrated
Del: useless -- https://master.php.net/note/delete/100714/useless
Del: bad code -- https://master.php.net/note/delete/100714/bad+code
Del: spam -- https://master.php.net/note/delete/100714/spam
Del: non-english -- https://master.php.net/note/delete/100714/non-english
Del: in docs -- https://master.php.net/note/delete/100714/in+docs
Del: other reasons-- https://master.php.net/note/delete/100714
Reject -- https://master.php.net/note/reject/100714
Search -- https://master.php.net/manage/user-notes.php