🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 目录辅助函数 目录辅助函数文件包含了一些帮助你处理目录的函数。 [TOC=2,3] ## [加载辅助函数](http://codeigniter.org.cn/user_guide/helpers/directory_helper.html#id4) 该辅助函数通过下面的代码加载: ~~~ $this->load->helper('directory'); ~~~ ## [可用函数](http://codeigniter.org.cn/user_guide/helpers/directory_helper.html#id5) 该辅助函数有下列可用函数: 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 返回类型: array 举例: ~~~ $map = directory_map('./mydirectory/'); ~~~ 注解 路径总是相对于你的 index.php 文件。 如果目录内含有子目录,也将被列出。你可以使用第二个参数(整数) 来控制递归的深度。如果深度为 1,则只列出根目录: ~~~ $map = directory_map('./mydirectory/', 1); ~~~ 默认情况下,返回的数组中不会包括那些隐藏文件。如果需要显示隐藏的文件, 你可以设置第三个参数为 true ~~~ $map = directory_map('./mydirectory/', FALSE, TRUE); ~~~ 每一个目录的名字都将作为数组的索引,目录所包含的文件将以数字作为索引。 下面有个典型的数组示例: ~~~ Array ( [libraries] => Array ( [0] => benchmark.html [1] => config.html ["database/"] => Array ( [0] => query_builder.html [1] => binds.html [2] => configuration.html [3] => connecting.html [4] => examples.html [5] => fields.html [6] => index.html [7] => queries.html ) [2] => email.html [3] => file_uploading.html [4] => image_lib.html [5] => input.html [6] => language.html [7] => loader.html [8] => pagination.html [9] => uri.html ) ~~~