This is my first time trying out the SPL iterators.
Im trying to figure out how to recursively move over a directory.
With the code that I've provided
1.  Is this the correct way to use it?  Im using recursive functions to
go deep.
   I thought, that the class would do that for me somehow...
2.  As it stands, it doesn't report the correct directory structure.
   For example, if I had a directory in the root with another directory
under it,
   the second directory doesnt get echoed.

Thanks

------
dirr('.');

function dirr($dir)
{
   $dir = new RecursiveDirectoryIterator($dir);

   foreach($dir as $foo)
   {
       echo $foo->getPathname() . '<br />';

       if ($foo->hasChildren())
       {
           $bar = $foo->getChildren();

           foreach($bar as $foo2)
           {
                if ($foo2->hasChildren())
                {
                    dirr($foo2->getPathname());
                }
                else
                {
                    echo $foo2->getPathName() . '<br />';
                }
           }
       }
   }
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to