title: Get Recursive List of Files with PHP
body: <p>I have been looking at a bunch of examples throughout Stack Overflow about getting a list of files recursively and storing them in a PHP array. Whatever it is that I am doing wrong is causing the array to be empty. Here is an portion of what I have.</p>
  
  <pre><code>&lt;?php
  $mediaFiles = array();
  function getFiles() {
      $media = "./media";
      foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($media)) as $filename){
          if ($filename-&gt;isDir()) continue;
          $mediaFiles[] = $filename-&gt;getPathname();
      }
  }
  getFiles();
  ?&gt;
  </code></pre>
  
  <p>Of course, that is part of it, and not all of it, but it is the relevant portion. I can't seem to figure out the issue, being that I am new to PHP. What am I doing wrong, or is there a better way to do this?</p>
  
  <p>The folder it should be getting the files from has about 800 files in it. So it definitely should not be empty.</p>