note 25382 added to function.mt-srand
| From: | ghaecker_no_spam at idworld dot net | Date: | Sat, 21 Sep 2002 06:20:45 +0000 |
| Subject: | note 25382 added to function.mt-srand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-37080@lists.php.net to get a copy of this message | ||
The range of unique seeds using this method is a bit over 2 billion. This approach also prevents
re-seeding.
function seed_mt_rand() {
static $done;
if (!$done) {
$hash = md5(microtime());
$length = ((substr($hash,0,1) < '8') ? 8 : 7 );
mt_srand((int)base_convert(substr($hash,0,$length),16,10));
$done = TRUE;
}
}
--
http://www.php.net/manual/en/function.mt-srand.php
http://master.php.net/manage/user-notes.php?action=edit+25382
http://master.php.net/manage/user-notes.php?action=delete+25382
http://master.php.net/manage/user-notes.php?action=reject+25382