note 57478 deleted from function.rand by felipe

[email protected]
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;
}
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.