Created
April 6, 2010 12:49
-
-
Save timjb/357553 to your computer and use it in GitHub Desktop.
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 | |
// Parameter: &directory | |
if(!function_exists('outputDir')) { | |
function outputDir($dir) { | |
if(substr($dir, -1) != '/') { | |
$dir .= '/'; | |
} | |
if(!is_dir($dir)) { | |
return $dir.' ist kein Verzeichnis!'; | |
} | |
$output = ''; | |
$files = scandir($dir); | |
if(count($files) > 2) { | |
$output .= '<ul>'; | |
for($i = 0; $i < count($files); $i++) { | |
if($files[$i] === '.' || $files[$i] === '..') { | |
continue; | |
} | |
if(is_file($dir.$files[$i])) { | |
$output .= '<li><a class="filelink" href="'.$dir.$files[$i].'">'.$files[$i].'</a></li>'; | |
} else if(is_dir($dir.$files[$i])) { | |
$output .= '<li>'.$files[$i]; | |
$output .= outputDir($dir.$files[$i]); | |
$output .= '</li>'; | |
} | |
} | |
$output .= '</ul>'; | |
} | |
return $output; | |
} | |
} | |
return outputDir($directory); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment