djkirstyjay Posted July 14, 2012 Share Posted July 14, 2012 I have a piece of code that I am trying to get the folders only within a specific images folder, as there's an index.htm file that I can't delete and I don't want it used in my code. I know I have to use is_dir, but for the life of me, I can't seem to put it in the correct place so that it works. Can anyone advise to put me out of my misery? Thanks in advance! $thumbs = "../thumbs/"; # Location of thumbs $images = "images/"; # Location of images $cols = 5; # Number of columns to display if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && is_dir($file)) { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo "<table> <tr> <tr>"; rsort($files); foreach($files as $file) { $fldrno = ereg_replace("folder", "", $file); if($colCtr %$cols == 0) echo "</tr><tr>"; echo "<td> <a href=\"" . $images . $fldrno . "/index.html\"> <img src=\"" . $thumbs . $fldrno . "/thumb.jpg\" alt=\"" . $alt . "\" /> </a> </td>"; $colCtr++; } echo "</table>" . "\r\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/265665-cant-seem-to-get-a-list-of-folders-within-rather-than-all-elements-in-a-folder/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.