Bug #17138: array_rand() is not random
| From: | d dot crawford at blueyonder dot co dot uk | Date: | Fri, 10 May 2002 11:29:10 +0000 |
| Subject: | Bug #17138: array_rand() is not random | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-7389@lists.php.net to get a copy of this message | ||
From: d.crawford@blueyonder.co.uk
Operating system: Windows 98
PHP version: 4.2.0
PHP Bug Type: Arrays related
Bug description: array_rand() is not random
The code from the manual:
srand ((float) microtime() * 10000000);
$input = array ("Neo", "Morpheus", "Trinity", "Cypher",
"Tank");
$rand_keys = array_rand ($input, 2);
print $input[$rand_keys[0]]."\n";
print $input[$rand_keys[1]]."\n";
always returns the same array elements.
--
Edit bug report at http://bugs.php.net/?id=17138&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17138&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17138&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17138&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17138&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17138&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17138&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17138&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17138&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17138&r=globals