Hi All
 
I could do with some pointers in using mt_strand.
 
I understand that because my server has <PHP4.2.0 random number
generators need to be seeded using mt_strand or mt_rand.
 
I have the following code [created with the help of this list]:
 
<?php
  $imgdir = /images/randomimages/";
  if ($handle = opendir($imgdir))
  {
    while (false !==($file = readdir($handle)))
      {
        if ($file != "." && $file != "..")
        {
          $random[] = $file;
        }
      }
      closedir($handle);
  } 
  $image = $random[mt_rand(0, count($random)-1)];
?>
<?php include("/images/randomimages/$image"); ?>
 
 and have found the following in the PHP manual:
 
<?php
// seed with microseconds
function make_seed() 
{
   list($usec, $sec) = explode(' ', microtime());
   return (float) $sec + ((float) $usec * 100000);
}
mt_srand(make_seed());
$randval = mt_rand();
?>
 
However - I'm not 100% sure how to incorporate it into my code - I have
tried a few things but each time I break the code.
 
Any help will be appreciated.
 
Thanks
Ange
***********************************
Angela K Hilton
Web & E-Learning Officer
ISD, UMIST
Tel: 0161 306 3109
***********************************
 

Reply via email to