note 57478 deleted from function.rand by felipe

From: Date: Sun, 30 Dec 2007 18:44:16 +0000
Subject: note 57478 deleted from function.rand by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134432@lists.php.net to get a copy of this message
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; }

« previous php.notes (#134432) next »