Hi Tamas, > > <?php > > for ($i=1; $i<=6; $i++) > > $x[] = mt_rand(1, 90); > > foreach ($x as $current) > > echo $current. "<br />"; > > ?> > > Thanks for help, but your program may generate same numbers between > the 5 generated numbers, hovewer I want to generate different numbers > such as lottery-numbers.
That's not a problem: just add a couple of lines to test for existence: $i = 0; while ($i<6) { $pick = mt_rand(1, 90); if (!in_array($pick, $x)) { $x[] = $pick; $i++; } } > But if this is the only solution I'll do it in this way. It's *never* the only solution :-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php