我目前卡在修改數組「平」到樹的數組結構。平面陣列到樹陣列
我有一個數組類型:
$folders = array(
array('Name' => 'Archive', 'Value' => 'Archive', 'Attributes' => 32, 'Delimiters' => '/'),
array('Name' => 'Folder1', 'Value' => 'Archive/Folder1', 'Attributes' => 32, 'Delimiters' => '/'),
array('Name' => 'FolderA', 'Value' => 'Archive/Folder1/DossierA', 'Attributes' => 64, 'Delimiters' => '/'),
array('Name' => 'Folder2', 'Value' => 'Archive/Folder2', 'Attributes' => 32, 'Delimiters' => '/'),
array('Name' => 'FolderA', 'Value' => 'Archive/Folder2/FolderA', 'Attributes' => 32, 'Delimiters' => '/'),
array('Name' => 'FolderB', 'Value' => 'Archive/Folder2/FolderA/FolderB', 'Attributes' => 64, 'Delimiters' => '/'),
);
,我會得到一個數組類型:
$treefolders = array(
array('Name' => 'Archive', 'Value' => 'Archive', 'Attributes' => 32, 'Delimiters' => '/', 'subnode' =>
array('Name' => 'Folder1', 'Value' => 'Archive/Folder1', 'Attributes' => 32, 'Delimiters' => '/', 'subnode' =>
array('Name' => 'FolderA', 'Value' => 'Archive/Folder1/FolderA', 'Attributes' => 64, 'Delimiters' => '/')
),
array('Name' => 'Folder2', 'Value' => 'Archive/Folder2', 'Attributes' => 32, 'Delimiters' => '/', 'subnode' =>
array('Name' => 'FolderA', 'Value' => 'Archive/Folder2/FolderA', 'Attributes' => 32, 'Delimiters' => '/', 'subnode' =>
array('Name' => 'FolderB', 'Value' => 'Archive/Folder2/FolderA/FolderB', 'Attributes' => 64, 'Delimiters' => '/')
)
)
)
);
我不知道怎麼去最後的結果。
你能幫我嗎?