note 10149 added to rand
| From: | blas at e-guys dot com | Date: | Fri, 15 Dec 2000 17:47:44 +0000 |
| Subject: | note 10149 added to rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-8762@lists.php.net to get a copy of this message | ||
Slightly Modified to create a Random Order Number, but converting to UpperCase for those who
don't want to deal with Case Sensitivity like me. Really just testting to see if this formats
correctly on php.
function genordernum ($order_num_len = 10)
{
$nps = "";
mt_srand ((double) microtime() * 1000000);
while (strlen($nps)<$order_num_len)
{
$c = chr(mt_rand (0,255));
if (eregi("^[A-Z0-9]$", $c)) $nps = $nps . strtoupper($c);
}
return ($nps);
}
http://www.php.net/manual/function.rand.php