Re: unique random number
| From: | Martin Thoma | Date: | Tue, 08 Aug 2000 15:49:43 +0000 |
| Subject: | Re: unique random number | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-10713@lists.php.net to get a copy of this message | ||
Bas Verschaar wrote:
>
> Hi,
>
> Every time i create a page, i want a random number (0..9) to be
> generated but it may not be the same number as the previous number
>
> so:
>
> srand((double)microtime()*1000000);
> $number = rand(0,9);
>
> with this code sometimes the value of $number is the same as the
> previous number
> is it in some way possible to solve this problem without using a
> database?
... you could use some other "random numbers" like microtime, time,
host_adr ect. and calculate them into the number somehow. You could also
use a piece of the number you get from uniquid (see php-manual).
Regards
Martin