Quantcast
Channel: snippet Feed
Viewing all articles
Browse latest Browse all 29

How to list files in a directory in PHP?

$
0
0

  1. <?php
  2. if($handle=opendir('/path/to/directory')){
  3.     echo"Directory handle: $handle\n";
  4.     echo"Entries:\n";
  5.     /* This is the correct way to loop over the directory. */
  6.     while(false!==($entry=readdir($handle))){
  7.         echo"$entry\n";
  8.     }
  9.  
  10.     closedir($handle);}
  11. ?>

Viewing all articles
Browse latest Browse all 29

Trending Articles