Posted By

ne7son on 07/05/12


Tagged

list file dir directory


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Some0ne


list all files in directory


 / Published in: PHP
 

list all files in directory and subdirectory

  1. <?php
  2. function recurly_list($path){
  3. $arrobiect = scandir($path);
  4. $arrname[0]=1;
  5. foreach($arrobiect as $name){
  6. if(($name == '.') || ($name=='..')){
  7.  
  8. }else{
  9.  
  10. if(is_dir($path.'\\'.$name)){
  11.  
  12. $arr = recurly_list($path.'\\'.$name);
  13. unset($arr[0]);
  14. $arrname = array_merge($arrname, $arr);
  15. }else{
  16.  
  17. array_push($arrname, $path.'\\'.$name);
  18.  
  19. }
  20. $i++;
  21. }
  22.  
  23. }
  24.  
  25. return $arrname;
  26. }
  27.  
  28.  
  29. $val = recurly_list('c:\\xampp\htdocs');
  30. print_r($val);
  31.  
  32. ?>

Report this snippet  

You need to login to post a comment.