I'm trying to create a "tree" structure from array of the paths, but I can't create create nesting like in example.
I'm "exploding" strings by "/" characted and do "for" loop for it, but somethig gone wrong and it's doesn't work.
A little example what I trying to do:
$files = [
'file.txt',
'another_file.txt',
'path/to_file.txt',
'path/to/file.txt',
];
// I need to get:
array(
'file.txt',
'another_file.txt',
'path' => array(
'to_file.txt',
'to' => array(
'file.txt'
// ...
),
)
)