Traverse directory - Find empty directory
| From: | Holografix | Date: | Wed, 27 Feb 2008 14:36:38 +0000 |
| Subject: | Traverse directory - Find empty directory | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-270524@lists.php.net to get a copy of this message | ||
Hi
I'm using Spl RecursiveDirectoryIterator to traverse a directory and have no
problem with it but now I'm stuck. I only need to display directories with
no files in it.
Can someone help with this?
My current code:
set_time_limit(0);
$files = new RecursiveIteratorIterator(new
RecursiveDirectoryIterator('c:\dev'),
RecursiveIteratorIterator::SELF_FIRST);
foreach($files as $file) {
if ($files->isDir()) {
echo $file . "<br/>";
}
}
I have
c:\dev
c:\dev\php
c:\dev\php\file1.php
c:\dev\php\file2.php
c:\dev\php\test
c:\dev\php\test\db
I would like to display 'test' because although there is a 'db' folder,
there are no files in c:\dev\php\test
Bets regards,
holo