Let's say I have this string which I want to put in a multidimensional array.
Edit : The number of subfolders in the string are dynamic .. from zero sub folders to 10
<?php
$string ="Folder1/Folder2/Folder3/filename1\n";
$string .=" Folder1/Folder2/Folder3/filename2\n";
$string .=" Folder4/Folder2/Folder3/filename3\n";
?>
I want the following array returned
<?php
Array
(
[Folder1] => Array
(
[Folder2] => Array
(
[Folder3] => Array
(
[0] => filename1
[1] => filename2
)
)
)
[Folder4] => Array
(
[Folder2] => Array
(
[Folder3] => Array
(
[0] => filename3
)
)
)
)
?>
What would be the most efficient way to accomplish this ?
And for the fun of it let's say this array will be send to the other side of the world and it wants to return to a string. How would we do that ?