Created
June 22, 2013 14:00
-
-
Save ertankayalar/5840965 to your computer and use it in GitHub Desktop.
directory list
This file contains hidden or 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 | |
| /* | |
| * To change this template, choose Tools | Templates | |
| * and open the template in the editor. | |
| */ | |
| if ($handle = opendir('/media/book')) { | |
| 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\n"; | |
| } | |
| /* This is the WRONG way to loop over the directory. */ | |
| while ($file = readdir($handle)) { | |
| echo "$file\n"; | |
| } | |
| closedir($handle); | |
| } | |
| ?> | |
| <?php | |
| /* | |
| * To change this template, choose Tools | Templates | |
| * and open the template in the editor. | |
| */ | |
| if ($handle = opendir('/media/book/')) { | |
| while (false !== ($file = readdir($handle))) { | |
| if ($file != "." && $file != "..") { | |
| echo "$file\n"; | |
| } | |
| } | |
| closedir($handle); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment