hey guys, i wonder how i can solve the following problem: I'm reading a folder on my server and i'm displaying the contents as follows. if there's an image i'll print an image, if there's folder i'll print a div with a folder icon. i wonder if it's possible click on one of those subfolders and then display the contents of this folder the exact same way I'm currently displaying the contents of the parent folder. it should work as kind of an endless loop if there are folders inside of folders.
$path = 'files';
if (($retval = scandir($path)) !== false) {
$retval = array_filter($retval, 'filter_files');
shuffle($retval);
}
function filter_files($file) {
return ($file != '.' && $file != '..' && $file != '.DS_Store' && $file != 'Thumbs.db');
}
//loop through shuffled files
foreach ($retval as $value) {
$ext = pathinfo($value, PATHINFO_EXTENSION); //file extension
if ($ext == "jpg" || $ext == "jpeg" || $ext == "gif" || $ext == "png") {
print "<img class='thumb' src='$path/$value'/>";
} else if ($ext == "") { //must be a folder
print "<div class='thumb folder'><a href=''>link_to_subfolder</a></div>";
} else {
//not supported
}
}
is that even possible?