note 57478 deleted from function.rand by felipe
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
Note Submitter: frank
----
re: Kniht
a little change to avoid a closed loop:
function rand_array($size, $min, $max) {
if ($size > $max)
$size = $max;
$v = array();
while ( count($v) < $size ) {
do {
$n = rand( $min, $max );
} while ( array_search($n, $v) !== false);
$v[] = $n;
}
return $v;
}