|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-10-31 17:01 UTC] crescentfreshpot at yahoo dot com
[2007-10-31 17:14 UTC] crescentfreshpot at yahoo dot com
[2007-11-07 18:59 UTC] colder@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 18:00:01 2025 UTC |
Description: ------------ The function Rand will produce predictable results. Reproduce code: --------------- <?php $array_random = array_fill(1,10,1); for($i=0;$i<100000000;$i++) { $array_random[rand(1,10)]++; } print_r($array_random); ?> Expected result: ---------------- This should produce an array which counts how many times each number is picked at random. It should return a different result each time. Actual result: -------------- Instead of getting purely random responses, we get predictable ones, in this example there will be tainted results, with numbers 5 and 10 producing lower counts: Array ( [1] => 10000594 [2] => 10000610 [3] => 10000633 [4] => 10000589 [5] => 9997562 [6] => 10000606 [7] => 10000568 [8] => 10000620 [9] => 10000645 [10] => 9997583 ) You will always see these types of return values.