Posted By

stancox on 10/21/09


Tagged

array files


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrianCoyDesign


Save files names in array


 / Published in: PHP
 

without scandir() function

  1. <?php
  2. if ($dir = @opendir(getcwd()))
  3. {
  4. while(($file = readdir($dir)) !== false)
  5. {
  6. if(is_dir($file)&&$file!=="."&&$file!=="..") { $array[] =$file." (dir)"; }
  7. elseif(is_file($file)) { $array[] =$file." (file)"; }
  8. }
  9. closedir($dir);
  10. }
  11. print_r($array);
  12. ?>

Report this snippet  

You need to login to post a comment.