RE: [PHP] Random Numbers
| From: | Jason Murray | Date: | Wed, 29 Nov 2000 03:46:00 +0000 |
| Subject: | RE: [PHP] Random Numbers | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-27763@lists.php.net to get a copy of this message | ||
Gary,
> My problem, when the numbers print they print like this.
> 703
> 7031
> 70310
>
> Does anyone know how to get different random numbers to print on the
> same page, Without the above happening?
It looks like you haven't seeded the random number generator?
<?
srand ((double) microtime() * 1000000);
$number1 = rand(111, 999);
$number2 = rand(1111, 9999);
$number3 = rand(11111, 99999);
?>
This Should(tm) (in an off-the-cuff kinda way) work.
Jason