title: unable to skip unreadable directories with RecursiveDirectoryIterator
body: <p>I want to get a list of all the subdirectories and my below code works except when I have readonly permissions on certain folders.  </p>
  
  <p>In the below question it shows how to skip a directory with RecursiveDirectoryIterator 
  <a href="https://stackoverflow.com/questions/4547485/can-i-make-recursivedirectoryiterator-skip-unreadable-directories">Can I make RecursiveDirectoryIterator skip unreadable directories?</a> however my code is slightly different here and I am not able to get around the problem.</p>
  
  <pre><code>$path = 'www/';
  foreach (new RecursiveIteratorIterator(
         new RecursiveDirectoryIterator($path,RecursiveDirectoryIterator::KEY_AS_PATHNAME),
              RecursiveIteratorIterator::CHILD_FIRST) as $file =&gt; $info) 
              {
                  if ($info-&gt;isDir())
                  {
                         echo $file . '&lt;br&gt;';                     
                  }
              }   
  </code></pre>
  
  <p>I get the error </p>
  
  <pre><code>Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(../../www/special): failed to open dir: Permission denied'
  </code></pre>
  
  <p>I have tried replacing it with the accepted answer in the other question.</p>
  
  <pre><code>new RecursiveIteratorIterator(
  new RecursiveDirectoryIterator("."), 
  RecursiveIteratorIterator::LEAVES_ONLY,
  RecursiveIteratorIterator::CATCH_GET_CHILD);
  </code></pre>
  
  <p>However this code will not give me a list of all the directories inside of www like I want, where am I going wrong here?</p>