|
Posted by Schraalhans Keukenmeester on 11/04/05 14:27
Heidi wrote:
> Philip Ronan wrote:
> : Didn't you notice the "5" in the brackets after get_rand_id?
> :
> : Try deleting it.
>
> yeah but the PHP lesson I was following said I could change it.
> I ended up ignoring that and ended up with this which is close to what I
> want:
> <?php
> $array = array (1 =>
> '1','2','3','4','5','6','7','8','9','10',
> '11','12','13','14','15','16','17','18','19','20',
> '21','22','23','24','25','26','27','28','29','30',
> '31','32','33','34','35','36','37','38','39','40',
> '41','42','43','44'
> );
>
> $rand_keys = array_rand($array, 6);
>
> $n1 = $array[$rand_keys[1]];
> $n2 = $array[$rand_keys[2]];
> $n3 = $array[$rand_keys[3]];
> $n4 = $array[$rand_keys[4]];
> $n5 = $array[$rand_keys[5]];
>
> print "Your Lotto Numbers are: <big>$n1, $n2, $n3, $n4, $n5,</big>";
> ?>
>
> and is shorter as well. Still got one more thing to add but it works:
> http://www.blackcat2.com/random4.php
>
> Coffee (and alt.www.webmaster) helped me think more clearly =)
>
> Thanks for the help,
> Heidi
>
>
Sidenote: mt_srand() is NOT necessary. PHP auto-seeds the generator when
using mt_rand().
Navigation:
[Reply to this message]
|