Read directory files to array


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

Alternative solution http://php.net/manual/en/function.glob.php


Copy this code and paste it in your HTML
  1. $dir = dir($path);
  2. $files_arr = array();
  3.  
  4. while (false !== $file = $dir->read()) {
  5. // Skip index file and pointers
  6. if(eregi(".php", $file) || substr($file, 0, 1) == ".")
  7. continue;
  8.  
  9. if(file_exists($path . '/' . $file))
  10. $files_arr[] = $file;
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.