View Single Post
Old 07-19-2005, 10:11 AM   #2 (permalink)
trache
Insane
 
trache's Avatar
 
you can easily do this:

Code:
$i = 1;
$myarray = array();
$exists = file_exists('brewery' . $i . '.jpg');
while ($exists = true)
{
   array_push($myarray, 'brewery' . $i . '.jpg');
   $exists = file_exists('brewery' . $i . '.jpg');
   $i++;
};
This will load up an array of images you are interested in. Note that this code does not pad your numbers with zeros first, ie, it will be brewery1.jpg not brewery01.jpg

Then, in your display code you could put:

Code:
if (in_array($id2 . '.jpg', $myarray))
{
    // display your image here
};
then, in your link code you can:

decrement or increment the variable of the image you are looking at by using $id2-- , $id2 = $id - 1 , or $id2++ or $id2 = $id2 + 1;

and then display the links, or only display the links if they are within range. There is an array_count() I believe that lets you know how many items you have in your array.

and in your main code that displays the image, and act on it if it does or doesn't (eg, just display the first/last image in your array if they go above or below the range of image numbers).

This is just one way of doing it. May not be efficient, but I thought it up off the top of my head.
__________________
"You looked at me as if I was eating runny eggs in slow motion." - Gord Downie of The Tragically Hip
trache is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76