Created
November 4, 2012 20:07
-
-
Save apphp-snippets/4013433 to your computer and use it in GitHub Desktop.
This code allows to list the contents of any given directory.
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 | |
| /* Source: http://www.apphp.com/index.php?snippet=php-list-directory-contents */ | |
| function list_directory_content($dir){ | |
| if(is_dir($dir)){ | |
| if($handle = opendir($dir)){ | |
| while(($file = readdir($handle)) !== false){ | |
| if($file != '.' && $file != '..' && $file != '.htaccess'){ | |
| echo '<a target="_blank" href="'.$dir.$file.'">'.$file.'</a><br>'."\n"; | |
| } | |
| } | |
| closedir($handle); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment