JS - Image Rotator?

Status
Not open for further replies.

Ronan O'F

New Member
Hi all.

I have a javascript code that is saved as a .JPG file, which scans the directory it is placed in, and displays a random image from that directory everytime the page is refreshed:

PHP:
<?php
$dh = opendir(".");
while (false !== ($file = readdir($dh))) 
{
  if (preg_match('/\.jpg$/i', $file) and $file != "avatar.jpg") // sanning for .jpg files only and stopping avatar.jpg being loaded (you will run into errors if this isnt here)
  {
     $filelist[] = $file;
  }
}
srand((double)microtime()*1000000);
$picnum = rand(0, sizeof($filelist) - 1);
header("Location: " . $filelist[$picnum]);
closedir($dh);
?>

I was wondering, could anyone edit this script to that it rotates through the images in the directory say every 6 or 7 seconds?

Thanks in advance, any questions, just ask.

RoF.
 
Status
Not open for further replies.
Top