|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #12312 Add array_mt_rand()
Submitted: 2001-07-22 21:23 UTC Modified: 2015-02-17 09:03 UTC
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: lramsey at crystalorb dot net Assigned:
Status: Wont fix Package: Arrays related
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
38 + 47 = ?
Subscribe to this entry?

 [2001-07-22 21:23 UTC] lramsey at crystalorb dot net
As the mt_rand() algorithim creates better random numbers than rand(), would it be possible to include in future releases of the language to include a version of array_rand() that uses mt_rand()?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-31 10:37 UTC]
Does array_shuffle() solve this?
 [2003-06-06 14:54 UTC]
There is no 'array_shuffle()' and shuffle() uses rand too.
Having array_mt_rand() is quite good idea. 

 [2003-06-06 17:33 UTC]
Why not just rewrite array_rand() and shuffle() to instead use mt_srand()?  It is "superior" after all...  And seeding takes place automatically as of PHP 4.2.0
 [2003-06-25 12:02 UTC]
There's a patch for php-src HEAD at 
Adds array_mt_rand(). Rewriting the existing functions 
would be bad for BC if anybody is relying on their current 
 [2010-12-31 21:13 UTC]
-Summary: array_mt_rand() ? +Summary: Add array_mt_rand() -Package: Feature/Change Request +Package: Arrays related -Operating System: Linux 2.4.3 +Operating System: * -PHP Version: 4.0.6 +PHP Version: *
 [2015-02-17 09:03 UTC]
-Status: Open +Status: Wont fix
 [2015-02-17 09:03 UTC]
array_rand does still use the same random number generator today, I checked.

What was true in 2003, is still true today in 2015, it would be a breaking change.

The introduction of a new function today requires an RFC, I'm therefore marking the bug as won't fix.

This report can still be found if some future RFC is started for the inclusion of the suggested function.

Sorry about the wait.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Sep 27 18:01:24 2023 UTC