Skip to content

Instantly share code, notes, and snippets.

@guillaumevoisin
Created June 7, 2012 13:22
Show Gist options
  • Save guillaumevoisin/2888792 to your computer and use it in GitHub Desktop.
Save guillaumevoisin/2888792 to your computer and use it in GitHub Desktop.
PHP: List files within a directory
if ($handle = opendir('/path/to/files')) {
echo "Directory handle: $handle\n";
echo "Entries:\n";
/* This is the correct way to loop over the directory. */
while (false !== ($entry = readdir($handle))) {
echo "$entry\n";
}
closedir($handle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment