USAF_Watson Posted June 3, 2011 Share Posted June 3, 2011 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.. Quote Link to comment https://forums.phpfreaks.com/topic/238274-quick-help-with-image-rotating-please/ Share on other sites More sharing options...
WebStyles Posted June 3, 2011 Share Posted June 3, 2011 Not sure if this is what you want, but check out the glob flags: GLOB_NOSORT - Return files as they appear in the directory (unsorted) hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/238274-quick-help-with-image-rotating-please/#findComment-1224580 Share on other sites More sharing options...
tastro Posted June 3, 2011 Share Posted June 3, 2011 just make an array(); of all your images and then just order them with sort(); or natsort(); what ever you need. Quote Link to comment https://forums.phpfreaks.com/topic/238274-quick-help-with-image-rotating-please/#findComment-1224592 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.