tags:

views:

583

answers:

3

I'm using this script to display all the images in a folder, but I can't figure out how to get each image's file name to display underneath it. Any suggestions?

<?php

$dirname = "images";
$images = scandir($dirname);
$ignore = Array(".", "..", "otherfiletoignore");

foreach($images as $curimg){
    if (!in_array($curimg, $ignore)) {
        echo "<img src='images/$curimg' /><br />\n";
    }
} 
?>
+4  A: 
echo "<img src='images/$curimg' /><br />$curimg<br />\n";
nickf
A: 

I think nickf's suggestion is the simplest thing you can do achieve what you want without any css or complex structure..

If you aren't answering the question, then comment (when you have enough rep) all these extra answers pollute the question.
Xenph Yan
It's a pain that you can't comment as soon as you join the site. If you ask a question you'll get enough rep pretty quickly though.
MattSmith
A: 

yuss!

That's amazing, thanks nickf.

I think my ultimate goal would be what you suggest, Milinda. Maybe when I have a firmer grasp on this whole thing (I'm very new to this game!)

Thanks guys

Allan