note 64106 deleted from function.array-rand by bjori

From: Date: Fri, 07 Apr 2006 14:58:02 +0000
Subject: note 64106 deleted from function.array-rand by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107524@lists.php.net to get a copy of this message
Note Submitter: vitor dot mattos at gmail dot com Reason: bad code ---- <?php // generate randon number without repeating function unique_rand($min, $max){ static $excessoes=array(); srand((float) microtime() * 10000000); $num=rand($min, $max); if(in_array($num, $excessoes)) $num = unique_rand($min, $max); $excessoes[]=$num; return $num; } // debuggin for($i=0;$i<=5;$i++) { echo unique_rand(0, 5)."<br>"; } ?>

« previous php.notes (#107524) next »