Quick Search:
 
 PHP Code: Directory Listing #2 Jump to:  
Category: >> PHP Code >> Directory Listing #2  

<< lastnext >>

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>'; 
 
?>


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org