TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Determine if this folder is the last level within that folder? (http://www.talkphp.com/general/5294-determine-if-folder-last-level-within-folder.html)

Peuplarchie 03-01-2010 03:42 AM

Determine if this folder is the last level within that folder?
 
Good day,
I'm working on a script and this script list folder in a html list.

Here is the code;

PHP Code:


<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 !

delayedinsanity 03-01-2010 04:27 AM

Use a for() loop in conjunction with count/sizeof(), and if $i < $count-1, you're on the last file.


All times are GMT. The time now is 10:27 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0