Determine if this folder is the last level within that folde

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

Determine if this folder is the last level within that folde

Post by Peuplarchie »

Good day,
I'm working on a script and this script list folder in a html list.

Here is the code;

Code: Select all

 
 
<html>
 
<head>
 
<style type="text/css">
 
ul {
 
      list-style-image: url(Icons/box_icon.png);
 
 
 
}
 
 
 
li li {
 
      list-style-image: url('Icons/open_book_icon.jpg');
 
 
 
}
 
 
 
li li li {
 
      list-style-image: url('Icons/gallery.gif');
 
}
 
 
 
</style>
 
</head>
 
<body>
 
 
 
 
 
 
 
<?PHP
 
function globDir($dir)
 
{
 
   $files = glob("$dir/*", GLOB_ONLYDIR);
 
   
 
     if(!empty($files))
 
   {
 
      echo "<ul>\n";
 
 
 
      foreach($files as $file)
 
      {
 
      echo "<li>";
 
 
 
 
 
      echo "<b>". basename($file)."</b>\n";
 
 
 
               globDir($file);
 
         echo "</li>\n";
 
      }
 
      echo "</ul>\n";
 
   }
 
}
 
globDir('Photos');
 
?>
 
 
 
</body>
 
</html>
 
 
example folder
|
- Folder 1
- Folder 2
|
- Folder2.1
|
- Folder3

The deal here is that I could go by CSS level of list but my problem is that sometime there is more subfolder yhat this example.

Is there a way that I can tell the last level folder to be written in bold ?



Thanks !
Post Reply