This is a script I am trying to create for my portfolio. I already part of it working. I can go get the images from the image folder no problem. I want to go a bit further than that. Here is an example of what is in that folder:site1_small.jpgsite1_large.jpgsite2_small.jpgsite2_large.jpgAnd so on...My php page contains something like this: <a href="site1_large.jpg"><img src="site1_small.jpg" alt="description" /></a>My problem is how can I be sure the href and src will be the corresponding small and large image? What about the description? I currently have it looping through all the images in that folder. I was thinking of having an array to store the small images, large images and the image description.Here's what I got:
<?php //Open images directory $dir = @ dir("../images/websites"); //List files in images directory while (($images = $dir->read()) !== false) { if(strstr($images, "_small")) { echo "<li><a href=\"/images/websites/site1_large.jpg\"><img src=\"/images/websites/" . $images . "\" alt=\"desription\" /></a></li>"; } } $dir->close(); ?>
I'd want to avoid using a db for this. Any ideas?