note 39854 rejected from function.srand by didou

From: Date: Fri, 13 Feb 2004 08:51:45 +0000
Subject: note 39854 rejected from function.srand by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-65085@lists.php.net to get a copy of this message
Note Submitter: greensleeves13@hotmail.com ---- 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...

« previous php.notes (#65085) next »