What I have is a list of file paths:
dir0/file0.txt
dir0/dir1/filea.txt
dir0/file1.txt
dir0/dir1/fileb.txt
dir0/dir1/dir1/filec.txt
dir0/file2.txt
What I'd like to get is something like the following:
$paths=Array(
file0.txt=>file0.txt,
dir1=>Array(
filea.txt=>filea.txt,
fileb.txt=>fileb.txt,
dir1=>Array(
filec.txt=>filec.txt
)
),
file1.txt=>file1.txt,
file2.txt=>file2.txt
);
It strikes me that this must be a fairly common requirement so it must've been solved plenty of times.
However, I'm not finding it easy to get my head round it.