Save files names in array


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

without scandir() function


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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.