多维数组,没有重复的字符串

I am attempting to create a multi-dimentional array from a mutable strings using "." as a delimiter I have attempted to do explode using "." but this doesn’t give the outcome I am looking for

Input

file1
file1.file2
file1.file3
file1.file3.file4
file5
file5.file6

I am looking for an outcome of

array("file1" => array("0" => "file1", file1.file2 = array("0" => "File2"), array("file1.file3" => array("0" => "file3", "file1.file3.file4" => array("0" =>"file4")),"file5" => array("0"=>"file5", "file5.file6" => array("0" => "file6")));

if anyone is able to help I would be much appreciated

Cheers

Vip32

after much more searching I have been able to find some code that produces the result I was looking for. if anyone is interested it is as follows

function AddFolder(array & $array, $string)
{
    $path = explode(".", $string);
    $aux =& $array;
    foreach($path as $key)
    {
        $patkey[] .= $key;
        $pathkey = implode(".", $patkey);
        if(isset($aux[$pathkey]))
        {
            $aux =& $aux[$pathkey];
        }else{
            $aux[$pathkey] = ["0" => $key];
            $aux =& $aux[$pathkey];
        }
    }
}

$arraylist = array();

foreach($list as $line)
{
    AddFolder($arraylist, $line);
}