note 96089 modified in function.mt-rand by danbrown
| From: | danbrown@php.net | Date: | Mon, 08 Feb 2010 13:54:50 +0000 |
| Subject: | note 96089 modified in function.mt-rand by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165745@lists.php.net to get a copy of this message | ||
Makes a random alpha numeric string of a given lenth
<?php
function makePin($lenth =5) {
// makes a random alpha numeric string of a given lenth
$aZ09 = array_merge(range('A', 'Z'), range('a',
'z'),range(0, 9));
$out ='';
for($c=0;$c < $lenth;$c++) {
$out .= $aZ09[mt_rand(0,count($aZ09)-1)];
}
return $out;
}
?>
--was--
Makes a random alpha numeric string of a given lenth
function makePin($lenth =5) {
// makes a random alpha numeric string of a given lenth
$aZ09 = array_merge(range('A', 'Z'), range('a',
'z'),range(0, 9));
$out ='';
for($c=0;$c < $lenth;$c++) {
$out .= $aZ09[mt_rand(0,count($aZ09)-1)];
}
return $out;
}
http://php.net/manual/en/function.mt-rand.php