Snippet Name: Directory Listing #2
Description: Lists all the items in a directory including folders and files.
Comment: (none)
Language: PHP
Highlight Mode: PHP
Last Modified: February 27th, 2009
|
<?PHP
// No slash at the end
$main_dir = 'path/to/dir';
$dirs = GLOB("{$main_dir}/*", GLOB_ONLYDIR);
$dirs = ARRAY_MAP('basename', $dirs);
$dirs = ARRAY_FILTER($dirs, 'no_underscore');
FUNCTION no_underscore($dirname){
RETURN $dirname[0] != '_';
}
ECHO '<pre>', PRINT_R($dirs, TRUE), '</pre>';
?> |