title: How to recursively display folders and sub folders with specific file types only using PHP5 RecursiveDirectoryIterator class
body: <p>Hi I am trying to get RecursiveDirectoryIterator class using a extension on the FilterIterator to work but for some reason it is iterating on the root directory only.</p>
  
  <p>my code is this.</p>
  
  <pre><code>    class fileTypeFilter extends FilterIterator
  {
      public function __construct($path)
      {
          parent::__construct(new RecursiveDirectoryIterator($path));
      }  
      public function accept()
      {
          $file = $this-&gt;getInnerIterator()-&gt;current();
          return preg_match('/\.php/i', $file-&gt;getFilename());
      }    
  
  }
  
  $it = new RecursiveDirectoryIterator('./');
  $it = new fileTypeFilter($it);
  
  foreach ($it as $file)
  {
      echo $file;
  }
  </code></pre>
  
  <p>my directory structure is something like this.</p>
  
  <pre><code>-Dir1
  --file1.php
  --file2.php
  -Dir2
  --file1.php
  </code></pre>
  
  <p>etc etc</p>
  
  <p>But as I said before the class is not recursively iterating over the entire directory structure and is only looking at the root. </p>
  
  <p>Question is, how do use a basic RescursiveDirectoryIterator to display folders and then run the FilterIterator to only show the php files in those directorys?</p>
  
  <p>Cheers</p>