你好,只是在寻求帮助,因为我被卡住了
我有两个字符串:
C:\Users\Bob\My Documents
/Users/Bob/Documents
这得到通过
preg_split('/(?<=[\/\\\])(?![\/\\\])/', $string)
返回
Array
(
[0] => C:\
[1] => Users\
[2] => Bob\
[3] => My Documents
)
Array
(
[0] => /
[1] => Users/
[2] => Bob/
[3] => Documents
)
我需要
Array
(
[C:\] => Array
(
[Users] => Array
(
[Bob] => Array
(
[My Documents] => array()
)
)
)
)
Array
(
[/] => Array
(
[Users] => Array
(
[Bob] => Array
(
[Documents] => array()
)
)
)
)
并最终合并为
Array
(
[C:\] => Array
(
[Users] => Array
(
[Bob] => Array
(
[My Documents] => array()
)
)
)
[/] => Array
(
[Users] => Array
(
[Bob] => Array
(
[Documents] => array()
)
)
)
)
(正确合并,而不仅仅是附加,所以如果另一个字符串以C:\Users\Dan
Then dan 开头,则会出现在第 3 个?维度。array_merge_recursive()
?)