So I am using this bit of PHP to display all the images in a particular directory:
<?php
$dirname = "cards/";
$images = glob($dirname."*.png");
foreach($images as $image) {
echo '<img src="'.$image.'" />';
}
?>
It works fine to load my images. But I am wondering how I can have it echo the html to not only load the image, but display the file name as alt and title attributes. I tried using the following but it loads up the dir name as well as the file name. Trying to just get the file name.
echo '<img src="'.$image.'" alt="'.$image.'" title="'.$image.'" />';
In addition, I want to display only five images per row, is there a way of formatting that with automatically generated images?
UPDATE: In regards to displaying five images at a time, I don't want a slider or pagination. I want all images in the dir loaded, but with a line break after every 5 images.
Thanks in advance!