The Directory Helper file contains functions that assist in working with directories.
This helper is loaded using the following code:
The following functions are available:
- directory_map($source_dir[, $directory_depth = 0[, $hidden = FALSE]])¶
- $source_dir (string) – Path to the source directory
- $directory_depth (int) – Depth of directories to traverse (0 = fully recursive, 1 = current dir, etc)
- $hidden (bool) – Whether to include hidden directories
An array of files
$map = directory_map('./mydirectory/');
Paths are almost always relative to your main index.php file.
Sub-folders contained within the directory will be mapped as well. If you wish to control the recursion depth, you can do so using the second parameter (integer). A depth of 1 will only map the top level directory:
$map = directory_map('./mydirectory/', 1);
By default, hidden files will not be included in the returned array. To override this behavior, you may set a third parameter to true (boolean):
$map = directory_map('./mydirectory/', FALSE, TRUE);
Each folder name will be an array index, while its contained files will be numerically indexed. Here is an example of a typical array:
Array ( [libraries] => Array (  => benchmark.html  => config.html ["database/"] => Array (  => query_builder.html  => binds.html  => configuration.html  => connecting.html  => examples.html  => fields.html  => index.html  => queries.html )  => email.html  => file_uploading.html  => image_lib.html  => input.html  => language.html  => loader.html  => pagination.html  => uri.html )