|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: lramsey at crystalorb dot net
New email:
PHP Version: OS:


 [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: Sat Dec 09 19:01:27 2023 UTC