I want to create a file tree, and for this I need to convert an array of files and directories to a multidimensional array of file trees. For instance:
array ( 'file.txt', 'dir1/', 'dir1/dir2/', 'dir1/dir2/dir3/', 'dir1/file.txt', )
to
array ( 'file.txt', 'dir1' => array ( 'dir2' => array ( 'dir3' => array(), ), 'file.txt', ) )
I tried to perform several functions but did not work. The problem I encountered, for example, is that there is no easy way to convert array ('test','test','test'),'test' to $array['test']['test']['test'] = 'test' .
Simon source share