title: Find directory structure in CodeIgniter
body: <p>This is my CodeIgniter code to find the directory structure of a folder in my own server, but it is only going one level deep. I want to list all the subdirectories in the given <code>$path</code>. What is the error in this code?</p>
  
  <pre><code>function finddir($path)
  {
      $this-&gt;load-&gt;helper('directory');
      $dir=directory_map($path,1);
      //echo"$path";
      foreach ($dir as $key =&gt; $subdir) 
      {
          //echo $subdir."&lt;br/&gt;";
          if(is_dir($subdir))
          {
              echo "&lt;h3&gt;$subdir&lt;/h3&gt;";
              $this-&gt;finddir($subdir);
          }
          else
          {
              echo "$subdir&lt;br&gt;";
          }
  
      }
  }
  </code></pre>
  
  <p>The output goes only one level deep. Since I'm using recursion, I want it to go into deeper levels.</p>