KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
PHP's rand() function doesn't give good random numbers. So I started to use mt_rand() which is said to give better results. But how good are these results? Are there any methods to improve them again? My idea: function rand_best($min, $max) { $generated = array(); for ($i = 0; $i < 100; $i++) { $generated[] = mt_rand($min, $max); } shuffle($generated); $position = mt_rand(0, 99); return $generated[$position]; } This should give you "perfect" random numbers, shouldn't it?
Tags (comma-separated)
Save Edits
Cancel