Note Submitter: tech_niek at users dot sourceforge dot net
----
If you want to generate two +different+ random numbers in the same range:
<?
function fn_arrRandom($min, $max){
// generate two random numbers
$iRandom1 = rand($min, $max);
$iRandom2 = rand($min, $max);
// compare them
if ($iRandom1 !== $iRandom2){
// the numbers are different, great
} else {
// the numbers are equal, try again
return fn_arrRandom($min, $max);
}
return array($iRandom1, $iRandom2);
}
print_r(fn_arrRandom(3, 13));
?>
The above will output two different random numbers in an array:
Array ( [0] => 5 [1] => 7 )
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.