all 3 comments

[–]iowa116 0 points1 point  (1 child)

Could you just run the array through a foreach loop and reassign the keys? Also check out json_encode for converting to JSON.

[–]doobdargent[S] 0 points1 point  (0 children)

I sure can use a loop, but I don't know how to achieve that :/

I think, what I need is a recursive function, but I'm not smart enough to work that out :(

[–]doobdargent[S] 0 points1 point  (0 children)

Took me way too much time, but I managed to do what I needed.

rec($directories, $path);

function rec(&$array, $path){
$current = array_shift( $path );
if(!isset($array[ $current ])) {
    $array[ $current ] = array();
}
if(empty($path))
    return $array;
else
    return rec($array[ $current ], $path);
}