title: Using CodeIgniter Directory Map Helper
body: <p>I'm trying to figure out how to use this directory_map function in CodeIgniter.
  See the manual for more details here: <a href="http://codeigniter.com/user_guide/helpers/directory_helper.html" rel="nofollow">http://codeigniter.com/user_guide/helpers/directory_helper.html</a></p>
  
  <p>Here is what I have working (kind of) and the result bellow:</p>
  
  <pre><code>$this-&gt;load-&gt;helper('directory');
  $map = directory_map('textfiles/');
  
  $index = '';
  
  foreach ($map as $dir =&gt; $file) {
    $idx .= "&lt;p&gt; dir: {$dir} &lt;/p&gt; &lt;p&gt; file: {$file} &lt;/p&gt;";
  } #foreach
  
  return $idx;
  </code></pre>
  
  <p>My testing environment directory and files structure:</p>
  
  <pre><code>one [directory]
    subone [sub-directory]
      testsubone.txt [file-in-sub-directory]
    testone.txt [file-in-directory-one]
  three [directory]
    testthree.txt [file-in-directory-three]
  two [directory]
    testing [sub-directory]
      testagain.txt [file-in-sub-directory-testing]
    test.txt [file-in-directory-testing]
  test.txt [file]
  </code></pre>
  
  <p>This is the output result I have in my view:</p>
  
  <pre><code>dir: 0
  dir: two
  file: Array
  dir: three
  file: Array
  dir: 1
  file: test.txt
  dir: one
  file: Array
  </code></pre>
  
  <p>As you can see in this result that not all directories or files are listed, some are showing up as an array.</p>
  
  <p>There is also something called "get_filenames" function in file helper. Maybe it can be used somehow with directory_map.</p>
  
  <p>Also, I get this following errors:</p>
  
  <pre><code>A PHP Error was encountered
  Severity: Notice
  Message: Array to string conversion
  Filename: welcome.php
  Line Number: #
  </code></pre>
  
  <p>Any help will be greatly appreceated. Thank you =)</p>