Quick Search:
Oracle PL/SQL Code Library
Find Or Post Oracle Jobs
Oracle Discussion & Chat
 PHP Code: Recursive Directory Browser Jump to:  
Category: >> PHP Code >> Recursive Directory Browser Bookmark and Share

<< lastnext >>

Snippet Name: Recursive Directory Browser

Description: This function takes in a directory path and recursively searches through the directory structure and returns all files in those directories. The file list is returned in an array.

This function has 1 required parameter and 2 optional parameters.

directoryToArray(Path to Directory [,file extention [,Display Full Path]]

If the file extension parameter is set, only files matching that extension will be displayed, ie, "jpg".

If the Display Full Path parameter is true, then the full path of the file will be returned. If it is false, only the file name will be returned. By default, this parameter is set to true.

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 01st, 2009

FUNCTION directoryToArray($directory, $extension="", $full_path = TRUE) {
     $array_items = ARRAY();
     IF ($handle = OPENDIR($directory)) {
          WHILE (FALSE !== ($file = READDIR($handle))) {
               IF ($file != "." && $file != "..") {
                    IF (IS_DIR($directory. "/" . $file)) {
                         $array_items = ARRAY_MERGE($array_items, directoryToArray($directory. "/" . $file, $extension, $full_path)); 
                    ELSE { 
                         IF(!$extension || (EREG("." . $extension, $file)))
                              IF($full_path) {
                                   $array_items[] = $directory . "/" . $file;
                              ELSE {
                                   $array_items[] = $file;
     RETURN $array_items;

Oracle Magazine
and Oracle White Papers

SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 32 users online    © 2009 psoug.org

Forgot your password?