Posted By

cornflakes on 03/05/08


Tagged

dir directory read Readdir


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

helloyj
MoFu
carlosabargues
fackz


Read Directory


 / Published in: PHP
 

Function used to read all file contents of a folder.

  1. 1.
  2. function dodir($dir) {
  3. 2.
  4. if ($handle = opendir($dir)) {
  5. 3.
  6. $files = array();
  7. 4.
  8. while (false !== ($file = readdir($handle))) {
  9. 5.
  10. if ($file != "." && $file != "..") {
  11. 6.
  12. $files[] = $file;
  13. 7.
  14. }
  15. 8.
  16. }
  17. 9.
  18. closedir($handle);
  19. 10.
  20. }
  21. 11.
  22. return $files;
  23. 12.
  24. }

Report this snippet  

You need to login to post a comment.