OK ich habs selber rausgefunden:
$ct = count($path)-1;
$ct_tmp = $ct;
// Ordner nur eine Ebene tief
if($ct == 0) { $tmp[$path[$ct_tmp]] = ""; }
// Ordner mehrere Ebenen tief
else
{
while($ct_tmp != -1)
{
// Erster durchlauf / letzter Ordner
if($ct_tmp == $ct) { $tmp2 = array( "$path[$ct_tmp]" => ""); }
// Zwishendurchlauf
else if($ct_tmp != 0)
{
$tmp2["$path[$ct_tmp]"] = $tmp2;
unset($tmp2[$path[$ct_tmp+1]]); // <--- !!!!!!!!!!!!!!!!
}
// letzter durchlauf
else
{
$tmp["$path[$ct_tmp]"] = $tmp2;
}
$ct_tmp--;
}
}