list all files in directory


/ Published in: PHP
Save to your folder(s)

list all files in directory and subdirectory


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.