Directory 輔助函數
目錄輔助函數檔包含協助目錄使用的函數。
載入 輔助函數
使用下列的程式碼載入補助程式:
$this->load->helper('directory');
下列為可以使用的函數:
directory_map('source directory')
此函數讀取第一個參數中指定的目錄路徑,建立一個以陣列表示該目錄包含的所有的檔案的資料。 參考範例:
$map = directory_map('./mydirectory/');
注意: 路徑總是相對於您的主要 index.php 檔
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);
每個資料夾名稱將是一個陣列索引,被包含的檔案將以數字表示作為陣列索引值。下面是陣列的一個典型的範例:
Array
(
[libraries] => Array
(
[0] => benchmark.html
[1] => config.html
[database] => Array
(
[0] => active_record.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
)