Re: Random numbers
| From: | Chris Lee | Date: | Fri, 24 Nov 2000 10:11:13 +0000 |
| Subject: | Re: Random numbers | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27066@lists.php.net to get a copy of this message | ||
Ahh I like this idea, I like different ideas, this is good. my code could
have been writen like this If I had thought of an idea like this.
<?
srand(time());
do
{
$tmp = rand(0, 9);
$rand[$tmp] = $tmp;
} while( count($rand) < 6 );
foreach($rand as $pos => $val)
echo "$rand[$pos]<br>\n";
?>
A much easier to read, and possibly faster method too. I havent timed it,
Im not sure which is faster. I like this alot better :)
Chris Lee
Mediawaveonline.com
rticle <Pine.LNX.4.30.0011250155350.13238-100000@aldi.fanstage.de>,
folke@fanstage.de wrote:
> <?
> while ($ok<6){
> $rand=rand(1,9);
> print "$rand<BR>\n"; if ($numbers[$rand]<2){
> $numbers[$rand]++;
> $ok++;
> }
> }
> ?>
>
>
>
>