TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Check if specific folder contains files, folders, both or none ? (http://www.talkphp.com/general/5289-check-if-specific-folder-contains-files-folders-both-none.html)

Peuplarchie 02-27-2010 01:09 AM

Check if specific folder contains files, folders, both or none ?
 
Good day to you all,
is there a way to check if a specific folder contains: files, folder, both or none ?

I read my folder with Glob, like my code here :

PHP Code:


<?PHP
function globDir($dir)
{
   
$files glob("$dir/*"GLOB_ONLYDIR);
   
     if(!empty(
$files))
   {
      echo 
"<ul>\n";

      foreach(
$files as $file)
      {
         echo 
"<li><b>"basename($file)."</b>\n";
         
globDir($file);
         echo 
"</li>\n";
      }
      echo 
"</ul>\n";
   }
}
globDir('Photos');
?>


The only thing I have really found is how to find if a specific file exists.

I'm trying to find out if a specific folder contains : files, folders, both, none.
It would return the appropriate word accordingly.

Thanks and take care!

Village Idiot 02-27-2010 04:36 AM

Have a look at this script, it can list the contents of a folder and discern between files and folders. You should be able to modify that to fit your needs.


All times are GMT. The time now is 01:39 AM.

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