Created
December 29, 2013 20:05
-
-
Save devluis/8174216 to your computer and use it in GitHub Desktop.
List images inside folder
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
<?php | |
if ($handle = opendir('myFolder')) { | |
echo "Directory handle: $handle\n"; | |
echo "Files:\n"; | |
/* This is the correct way to loop over the directory. */ | |
while (false !== ($file = readdir($handle))) { | |
echo $file."<br />"; | |
} | |
/* This is the WRONG way to loop over the directory. */ | |
while ($file = readdir($handle)) { | |
echo "$file\n"; | |
} | |
closedir($handle); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment