Last active
December 18, 2015 19:19
-
-
Save philsinatra/5831744 to your computer and use it in GitHub Desktop.
PHP sample showing how to output the files in a 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 | |
// define the directory location | |
$dir = 'directoryname'; | |
// open the directory | |
if ($handle = opendir($dir)) { | |
while (false !== ($entry = readdir($handle))) { | |
// ignore invisible files | |
if ($entry != '.' && $entry != '..' && $entry != '.DS_Store') { | |
// build a list of the contents of the directory | |
echo '<li>'; | |
echo '<a href="' . $dir . $entry . '" target="_blank">'; | |
echo substr($entry, 0, -5); | |
echo '</a>'; | |
echo '</li>'; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment