note 83100 added to function.array-rand
| From: | knoffz at gmail dot com | Date: | Fri, 09 May 2008 20:44:59 +0000 |
| Subject: | note 83100 added to function.array-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139226@lists.php.net to get a copy of this message | ||
"As of PHP 4.2.0, there is no need to seed the random number generator with srand() or
mt_srand() as this is now done automatically."
Do not trust in this! I tried to fill a database with 100.000 unique id's (in a loop). Each id
7 chars long with a numeric-loweralpha charset. When it came to around ~17.500 queries, the
array_rand() function was unable to generate a new unique id from the charset. I don't think
it's a bug. However, make sure to seed the random number generator by yourself. Either by
adding _ srand((float) microtime() * 10000000); _ before the array_rand() function, or by shuffling
the array first. PHP version was 5.2.5 by the way...
----
Server IP: 212.124.37.9
Probable Submitter: 84.128.229.129
----
Manual Page -- http://www.php.net/manual/en/function.array-rand.php
Edit -- https://master.php.net/note/edit/83100
Del: integrated -- https://master.php.net/note/delete/83100/integrated
Del: useless -- https://master.php.net/note/delete/83100/useless
Del: bad code -- https://master.php.net/note/delete/83100/bad+code
Del: spam -- https://master.php.net/note/delete/83100/spam
Del: non-english -- https://master.php.net/note/delete/83100/non-english
Del: in docs -- https://master.php.net/note/delete/83100/in+docs
Del: other reasons-- https://master.php.net/note/delete/83100
Reject -- https://master.php.net/note/reject/83100
Search -- https://master.php.net/manage/user-notes.php