can anyone tell my why the $output array is always only the last $tmp array of the foreachloop.
im pulling hairs here..
private function create_dir_array($dirs) {
$output = array();
foreach ($dirs as $key => $path) {
$path = split('/',$path);
$tmp = array();
$counter = count($path)-1;
for($i = $counter; $i >= 0; $i--)
{
$tmp = array($path[$i] => $tmp);
}
$output = array_merge($output, $tmp);
}
print("<pre>".print_r($output,true)."</pre>");
}
if have this array
Array
(
[0] => archive/folder1
[1] => archive/folder1/subfolder1
[2] => archive/folder2
.....
)
and i want that array out of the given data may anyone has a better simpler idea for this?
Array
(
[archive] => Array(
[folder1] => Array(
[subfolder1] => Array()
)
)
[folder2] => Array(
......
)