Using function directory_map - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Using function directory_map (/showthread.php?tid=10145) Pages:
1
2
|
Using function directory_map - El Forum - 07-20-2008 [eluser]polaris1927[/eluser] I am using the Code: directory_map($path) However, it seems Code: directory_map($path) My question is this: is there a way that I can get the full sub-directory paths when using directory_map? Thanks Using function directory_map - El Forum - 07-20-2008 [eluser]Colin Williams[/eluser] Are you sure. Works just that way for me. Files are strings and folders area keyed arrays, so make sure in your loop your using $key => $value in your loop. If $value is an array, $key is your folder name. Using function directory_map - El Forum - 07-21-2008 [eluser]polaris1927[/eluser] Thanks for the reply Yes, I am able to get the folder and file names, but I want the path to those sub folders. for example if $path = '/home/test'; --Main folder (array) --- Sub folder 1 (array) ------- sub folder 1.1 (array) --- Sub fouler 2 (array) ------- Sub folder 2.1 (array) ------- sub folder 2.2 (array) Using directory_map returns folders as arrays; I need the actual path of the sub folders /home/test/Main folder /home/test/Main folder/Sub folder 1 /home/test/Main folder/sub folder 1/sub folder 1.1 Using function directory_map - El Forum - 07-21-2008 [eluser]Colin Williams[/eluser] Well then, recurse the array and store each level along the way. Using function directory_map - El Forum - 07-21-2008 [eluser]polaris1927[/eluser] What would be the best approach to acieve this, could you post an example code structure to explain what you mean? Thanks Using function directory_map - El Forum - 07-21-2008 [eluser]Colin Williams[/eluser] By what means do you wish to retrieve the structure? Do you want to fetch a string with a certain folders complete structure, or do you wish to fetch an array where each value is a full path to a folder in the map? Using function directory_map - El Forum - 07-21-2008 [eluser]polaris1927[/eluser] Where each value is a full path. Using function directory_map - El Forum - 07-21-2008 [eluser]Colin Williams[/eluser] I loves me some recursion! Call this function like you would call directory_map(), or call it with 1) A folder path to prefix your array values and 2) a map already returned by directory_map(). Be sure to load directory helper first, or better yet, put this and directory_map() in your own helper. Code: function directory_map_paths($wp = '', $map = array()) Using function directory_map - El Forum - 07-21-2008 [eluser]polaris1927[/eluser] Thanks! Using function directory_map - El Forum - 07-21-2008 [eluser]Colin Williams[/eluser] Shit yeah, polaris! You owe me a beer. |