note 29565 added to function.mt-srand
| From: | mrcheezy at hotmail dot com | Date: | Mon, 17 Feb 2003 20:14:00 +0000 |
| Subject: | note 29565 added to function.mt-srand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-44109@lists.php.net to get a copy of this message | ||
Very good points above on seeds, thank you. If you would like to test a seed try using the code
below. It will take between 5 and 20 seconds depending on your system and then will spit out the
number of reused keys out of 100,000 attempts.
; for ($i=0; $i<100000; $i++) {
; mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
; $rand = mt_rand();
;
; ($arr[$rand] == '1') ? $k++ : $arr[$rand] = '1';
; }
--
http://www.php.net/manual/en/function.mt-srand.php
http://master.php.net/manage/user-notes.php?action=edit+29565
http://master.php.net/manage/user-notes.php?action=delete+29565
http://master.php.net/manage/user-notes.php?action=reject+29565