Help with image array

Discussion in 'PHP' started by jazzzyman, May 14, 2011.

  1. #1
    Hi all]

    need help with an image array

    what im hoping is possible is

    i have say 10 folders
    each folder is an image category

    the array would randomly (say for 10 secs) display an image which would link to the category page

    so it picks an image from any folder category, displays it and then links off to the category page

    now is it possible to set it so each specific folder is linked to a specific page? rather than having to assign a link to every image it would know if picked from folder a, then link to category a

    if possible please let me know
     
    jazzzyman, May 14, 2011 IP
  2. hav0k

    hav0k Active Member

    Messages:
    178
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Of course you can! All you would have to do is strip the filename from the end of the image url you grabbed with your script and you would then have the url to the directory the image is from. Or if you weren't looking to link to that folder you can parse the url of the image and grab the name of the folder it was in from that.

    Check out some of php's directory functions: http://www.php.net/manual/en/ref.filesystem.php
    * specifically opendir() and readdir()

    explode() might be useful as well: http://www.php.net/manual/en/function.explode.php

    Hope that helps!
     
    hav0k, May 14, 2011 IP