Posted By

stz184 on 10/02/11


Tagged


Versions (?)

List files in folder


 / Published in: PHP
 

This function accept one parameter - string, dir path. It will return a array, containing all files found in this and all its subfolders.

  1. function listing($dir) {
  2. $result = array();
  3. foreach (glob($dir.'/*') as $filename) {
  4. if(is_file($filename)) {
  5. $result[] = $filename;
  6. }
  7. else {
  8.  
  9. $result = array_merge(listing($filename), $result);
  10. }
  11. }
  12. return $result;
  13. }

Report this snippet  

You need to login to post a comment.