Jump to content

Quick help with image rotating please..


USAF_Watson

Recommended Posts

My script is as following,

 

<?php

 

//Change the imgdir variable to wherever you want the script to look for images.

$imgdir = "Image/directory";

 

//Change time to how often the images should change (in seconds)

$time = 10;

 

 

header('content-type: image/jpg');

if($imgdir != "image/directory")

{

$files = glob("/" . $imgdir . "/*.jpg");

} else {

$files = glob("*.jpg");

}

echo file_get_contents($files[abs((time() / $time) % (count($files)))]);

?>

 

 

What is happening is the images within the directory are going all random. Shouldnt this code be showing the images in alphabetical/numerical order in which they are named? If not can someone please tell me what Im doing wrong..

Link to comment
https://forums.phpfreaks.com/topic/238274-quick-help-with-image-rotating-please/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.