Created
June 7, 2012 13:22
-
-
Save guillaumevoisin/2888792 to your computer and use it in GitHub Desktop.
PHP: List files within a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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