note 39854 added to function.srand

From: Date: Fri, 13 Feb 2004 01:57:53 +0000
Subject: note 39854 added to function.srand
Groups: php.notes 
Request: Send a blank email to php-notes+get-65073@lists.php.net to get a copy of this message
If we reseed the srand with a number generated by rand, would we still get a "good" random series? then maybe we can solve the problem of multiple seeding by 3rd party components.... function myrand (n, x) { if (!$GLOBALS['myseed']) { $GLOBALS['myseed'] = (double)microtime()*1000000; } else { $GLOBALS['myseed'] = rand(0,1000000); } srand($GLOBALS['myseed']); return rand(n, x); } but of course, this is a lot of overhead, if it works at all. the best solution would still be up to PHP to fix its srand... ---- Manual Page -- http://www.php.net/manual/en/function.srand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39854 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39854&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39854&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65073) next »