title: Using php to create a Folder select list - including child folders?
body: <p>I'm trying to use scandir to display a select list of folders listed in a specific directory (which works fine) however, I need it to also add the child folders (if there are any) into my select list. If anyone could help me, that would be great!</p>
  <p>This is the structure I want:</p>
  <pre><code>&lt;option&gt;folder 1&lt;/option&gt;
  &lt;option&gt; --child 1&lt;/option&gt;
  &lt;option&gt; folder 2&lt;/option&gt;
  &lt;option&gt; folder 3&lt;/option&gt;
  &lt;option&gt; --child 1&lt;/option&gt;
  &lt;option&gt; --child 2&lt;/option&gt;
  &lt;option&gt; --child 3&lt;/option&gt;
  </code></pre>
  <p>And this is the code I have (which only shows the parent folders) which I got from this thread (<a href="https://stackoverflow.com/questions/608450/using-scandir-to-find-folders-in-a-directory-php">Using scandir() to find folders in a directory (PHP)</a>):</p>
  <pre><code> $dir = $_SERVER['DOCUMENT_ROOT'].&quot;\\folder\\&quot;;
  
   $path = $dir;
   $results = scandir($path);
  
   $folders = array();
   foreach ($results as $result) {
      if ($result == '.' || $result == '..') continue;
      if (is_dir($path . '/' . $result)) {
        $folders[] = $result;
      };
   };
  </code></pre>
  <p>^^ but I need it to show the child directories also. I don't want the files, only the folders.</p>