Skip to content

Instantly share code, notes, and snippets.

@fitsum
Created June 12, 2014 15:33
Show Gist options
  • Save fitsum/e50c74be0e6ab4c419db to your computer and use it in GitHub Desktop.
Save fitsum/e50c74be0e6ab4c419db to your computer and use it in GitHub Desktop.
Lists files & directories recursively
// lists files & directories recursively
<?
function menu($dir){
$files = glob($dir.'/*');
$html = '<ul>';
foreach($files as $file){
if(is_dir($file)){
// FB 6/12
// added bc it wasn't tharr
// make collapsable
$html .= '<li>'. basename($file,'.php') .'</li>';
$html .= menu($file);
}else{
// make collapsable
$html .= '<li><a target="_blank" title="Opens in a new window" href="'. $file .'">'. basename($file,'.php') .'</a></li>';
}
}
$html .= '</ul>';
return $html;
}
echo menu("./*");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment