Ok i cant get $image to be defined It is supposed to read the directory its in for the specified file type : foreach (glob("*.jpg") as $image); PHP: there are multiple image of the same filetype in the directory what is wrong with the code? <?php foreach(glob("*.gif") as $image); echo '<img src="./$image" /></td>'; ?> <br> <?php foreach(glob("*.jpg") as $image); echo '<img src="./$image" /></td>'; ?> <br> <?php foreach(glob("*.jpeg") as $image); echo '<img src="./$image" /></td>'; ?> <br> <?php foreach(glob("*.png") as $image); echo '<img src="./$image" /></td>'; ?> <br> <?php foreach(glob("*.PNG") as $image); echo '<img src="./$image" /></td>'; ?> PHP: ;
Also, I'm pretty sure you're wanting to display the filename of several files, so you want to use this, otherwise you'll only echo the info for one image - the last image found: <?php $images = glob("/path/to/images/{*.gif,*.jpg,*.jpeg,*.png,*.PNG}", GLOB_BRACE); foreach($images as $image) { echo '<img src="./$image" /></td>'; } ?> PHP: