Reputation: 321
I have this script that runs through all subdirectories of the directory images and prints out all the images.
<?php
$dirname = 'images/*/';
$images = glob($dirname . "*");
foreach ($images as $image) {
echo '<img src="' . $image . '" class=image /><br>';
}
?>
I also want to know the name of the subdirectories (the "*" in $dirname) where each image has been taken from so I can print it out.
So in the browser it should come out like this:
Upvotes: 1
Views: 46
Reputation: 78984
Get the directory name and then get the trailing part of that:
echo basename(dirname($image));
Upvotes: 1