Re: Re: How can I get a random number
| From: | Chris Lee | Date: | Wed, 17 Jan 2001 15:38:23 +0000 |
| Subject: | Re: Re: How can I get a random number | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-35051@lists.php.net to get a copy of this message | ||
This might not be quite what your looking for, but I often have then need
for a unique number in an incrementing order. random isnt quite the word for
it, unique is :)
function mtime()
{
$mtime = microtime();
$mtime = str_replace("\.", '', $mtime);
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] . $mtime[0];
return($mtime);
}
Chris Lee
Mediawaveonline.com
"Angela" <angela@localnetamerica.com> wrote in message
news:3A64C758.36B53CAE@localnetamerica.com...
> I see that you got a lot of responses, but I didn't see anyone using
> what I use. I had problems using rand() because it wasn't quite random
> enough. The following code is as random as you can get (at least from
> what I've seen).
>
> mt_srand ((double) microtime() * 1000000);
> $myrandomnumber = mt_rand($min_number, $max_number);
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>