JS - Image Rotator?

Discussion in 'Coding Help' started by Ronan O'F, Sep 24, 2010.

  1. Ronan O'F

    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(0sizeof($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.
     

Share This Page