note 54722 added to function.rand

From: Date: Wed, 13 Jul 2005 17:00:09 +0000
Subject: note 54722 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-91910@lists.php.net to get a copy of this message
I need to generate large arrays of random numbers within specific ranges. The function provided by mark at mmpro dot de is good stuff, but if the range of your random numbers ($max - $min) is less than the number of elements in the array ($num), i.e. you want to permit duplicate values, then: Alter this line: while (in_array($a,$ret)); to this: while (next($ret)); ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54722 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54722&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54722&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54722&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54722&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54722&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54722&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54722&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91910) next »