title: PHP scandir - multiple directories
body: <p>I am creating a WordPress plugin which allows a user to apply sorting rules to a particular template (page, archive, single etc). I am populating list of pages using PHP scandir like so:</p>
  
  <pre><code>$files = scandir(get_template_directory());
  </code></pre>
  
  <p>The problem is that I keep single.php templates in a '/single' subfolder so these templates are not being called by the above function.</p>
  
  <p>How can I use multiple directories within the scandir function (perhaps an array?) or will I need a different solution?</p>
  
  <p>So basically I am trying to:</p>
  
  <pre><code>$files  =   scandir( get_template_directory() AND get_template_directory().'/single' );
  </code></pre>
  
  <p>My current solution (not very elegant as it requires 2 for each loops):</p>
  
  <pre><code>        function query_caller_is_template_file_get_template_files()
              {
                  $template_files_list    =   array();
  
                  $files          =   scandir(get_template_directory());
                  $singlefiles    =   scandir(get_template_directory().'/single');
  
                  foreach($files  as  $file)
                      {
                          if(strpos($file, '.php')    === FALSE)
                              continue;
  
                          $template_files_list[]  =   $file;
                      }
  
                  foreach($singlefiles  as  $singlefile)
                      {
                          if(strpos($file, '.php')    === FALSE)
                              continue;
  
                          $template_files_list[]  =   $singlefile;
                      }
  
                  return $template_files_list;
              }
  </code></pre>