I use this code to return random numbers without duplicates. I can't remember where I got it from but it isn't my code.
Usage:Code://returns an array of random keys between 2 numbers
function &UniqueRands($min, $max, $keys){
static $returnme = array();
while(in_array($x = rand($min,$max),$returnme));
$returnme[] = $x;
if($keys < count($returnme)-1 && $keys < ($max-$min))
UniqueRands($min, $max, $keys);
return $returnme;
}
Code://usage
$rands = & UniqueRands(0, 15, 5);
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks