Hi,
I'm writing a file manager for a school org I'm in. My question is this, currently, when I have someone navigate through directories and they want to go one up I simply append ../ to the directory path. Since this is done in a series of places and it is fairly convenient, I don't think I'm going to change this. The problem, however, is that after some browsing you end up with a path along the lines of "../dev/sample1/../sample2/../sample3/../" instead of simply "../dev/". This becomes very problematic if one of the folders I've previously browsed was deleted (in which case the whole algorithm breaks). What I need to do is create a function that would take in the currentpath $curpath (which can be ugly and long) and spit out the optimized path (so, to return back to my example, I want to be able to pass the function "../dev/sample1/../sample2/../sample3/../" and have it return "../dev/"). I tried to make an algorithm by splitting the path by split($curpath,"/") and then removing parts of the array that precede ".." but it doesn't really work.
Hope you can help me,
Thank you in advance,
Ilya V