> OK I want to pick 5 random numbers from 1 to 200. Easy.
> They must all be different. Not so easy.
<?
srand ((double) microtime() * 1000000);
while (count($selectednumbers) < 5)
{
$randomnumber = rand(1, 200);
if (!in_array($randomnumber, $selectednumbers))
{
$selectednumbers[] = $randomnumber;
}
}
//$selectednumbers is now an array with 5 items between 1 and 200.
?>
This should work well enough to give you the general idea ... sorry if it
doesn't, I grabbed some old code and modified it so I didn't embarrass
myself too much by posting spaghetti code. :)
Jason
--
Jason Murray
[EMAIL PROTECTED]
Web Developer, Melbourne IT
"Work now, freak later!"
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]