title: php RecursiveDirectoryIterator: how to exclude directory paths with a dot and double dots?
body: <p><code>RecursiveDirectoryIterator</code> seems to give me two different results from my localhost and live server,</p>
  
  <pre><code>define ('WEBSITE_DOCROOT', str_replace('\\', '/', dirname(__FILE__)).'/');
  
  print_r(WEBSITE_DOCROOT);
  
  // List all the class directories in the array.
  $main_directories = array(
      'core/model/',
      'core/helper/',
      'core/ext/'
  );
  
  // Set other vars and arrays.
  $sub_directories = array();
  
  // List any sub dirs in the main dirs above and store them in an array.
  foreach($main_directories as $path_directory)
  {
      $iterator = new RecursiveIteratorIterator
      (
          new RecursiveDirectoryIterator(WEBSITE_DOCROOT.$path_directory), // Must use absolute path to get the files when ajax is used.
          RecursiveIteratorIterator::SELF_FIRST
      );
  
      foreach ($iterator as $fileObject) 
      {
          if ($fileObject-&gt;isDir()) 
          {
              //if($fileObject-&gt;isDir() === '.' || $fileObject-&gt;isDir() === '..') {continue;} 
  
              // Must trim off the WEBSITE_DOCROOT. 
              $sub_directories[] = preg_replace('~.*?(?=core|local)~i', '', str_replace('\\', '/', $fileObject-&gt;getPathname())) .'/';
          }
      }
  }
  
  // Mearge the main dirs with any sub dirs in them.
  $merged_directories = array_merge($main_directories,$sub_directories);
  print_r($merged_directories);
  </code></pre>
  
  <p>localhost,</p>
  
  <pre><code>(
      [0] =&gt; core/model/
      [1] =&gt; core/helper/
      [2] =&gt; core/ext/
  )
  </code></pre>
  
  <p>live server,</p>
  
  <pre><code>(
      [0] =&gt; core/model/
      [1] =&gt; core/helper/
      [2] =&gt; core/ext/
      [3] =&gt; core/model/./
      [4] =&gt; core/model/../
      [5] =&gt; core/helper/./
      [6] =&gt; core/helper/../
      [7] =&gt; core/ext/./
      [8] =&gt; core/ext/../
  )
  </code></pre>
  
  <p>So, how can I exclude the directory paths with <strong>a dot and double dots</strong>?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Live server - PHP version 5.3.27
  Localhost - PHP version 5.5</p>