Posted By

mikael12 on 01/11/11


Tagged

read-dir-array


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

AllKnightAccess
floweb


Read directory files to array


 / Published in: PHP
 

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

  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  

You need to login to post a comment.