get an array containing random integers between $min and $max integers
Trying to pick up random keys from an array but don’t want any duplicates?
try this
-
-
<?php
-
//returns an array of random keys between 2 numbers
-
function &UniqueRands($min, $max, $keys, $reset=true){
-
//while is used to avoid recursive the whole function
-
$returnme[] = $x;
-
//$keys are the number of random integers in the array
-
//must not be more than the sub of max – min
-
UniqueRands($min, $max, $keys,false);
-
return $returnme;
-
}
-
//usage
-
$rands = & UniqueRands(0, 100, 30);
-
//with an array
-
foreach($rands as $x)
-
?>
-
