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
I think this what you want,
$string ="Folder1/Folder2/Folder3/filename1\n";
$string .="Folder1/Folder2/Folder3/filename2\n";
$string .="Folder4/Folder2/Folder3/filename3\n";
$string_array_1 = explode("\n", $string);
$array_need = array();
foreach($string_array_1 as $array_values)
{
if($array_values)
{
$folders = explode("/", $array_values);
$array_need[$folders[0]][$folders[1]][$folders[2]][] = $folders[3];
}
}
print_r($array_need);