Forum Moderators: coopster
Please could the experts in here review my below script and see where I am going wrong.
<?php
$path = getcwd();
foreach(scandir("$path/photos/") as $album) {
if(is_dir($album)) {
print "<a href=\"view.php?album=$album\">"; //This is where the images would be shown
print str_replace("-", ' ', "$album"); //Simply replacing the hiphens in the subfolder when it is echo'd.
print "</a>\n";
}
}
?>
**The entire path for the files would be d://website/photos/folder-with-images/
Any help in any form is highly appreciated.
Many thanks - Melwyn
<?php
$album = $_GET['album']; //from previous page
$path = getcwd(); //current working directory
chdir ('photos'); //directory for photos or albums
$path = getcwd(); //the new directory
echo getcwd(); //showing the current directory
foreach (glob("$path/$album/*.JPG") as $imgfile) {
echo "<img src='$imgfile' />" ."\n";
}
?>
Any ideas on how to get these slahses in the right way?
Many thanks for any help and assistance.
Kind regards
Melwyn
When you run this on Linux it will be forwardslashes.
You could always do a str_replace() [uk3.php.net] to fix it if it is bugging you that much :)