I have this array :
Array
(
[0] => index.html
[libraries] => Array
(
[0] => benchmark.html
[1] => config.html
[database] => Array
(
[0] => active_record.html
[1] => binds.html
[hey] => Array
(
[0] => test.html
)
)
[2] => email.html
)
)
This is an array representing a tree of folders (arrays) and files (.html). I want to display on my page all the .html files with their path like :
index.html
libraries/benchmark.html
libraries/config.html
libraries/database/active_records.html
libraries/database/binds.html
libraries/database/hey/test.html
libraries/email.html
Here is my function but I don't achieve to display the parent key name:
private function map_dirs($dirs) {
$dirs_list = array();
$i = 0;
$keys = array_keys($dirs);
foreach($dirs as $dir) {
if(is_array($dir))
$dirs_list = array_merge($dirs_list, $this->map_dirs($dir));
else
$dirs_list[] = $keys[$i].'/'.$dir;
$i++;
}
return $dirs_list;
}
Any idea ?