There are of course two obvious ways this can be done:
1) compare a hash of two directory paths or as is without a hash.
2) split each folder into a array and iteratively compare each element with the other array
The latter has the benefit of usually being more accurate. For instance depending on the server and system sometimes you have a path (from either $_SERVER['DOCUMENT_ROOT'] or other) where you have a leading or trailing slash added and other times not, so when comparing directories using a hash or a direct string comparison, you need to take caution into ensuring those caveats are removed. Otherwise two identical paths (resolve to the same object) may very well not compare as equals in code.
For former has the appeal of being easy to implement, trivial as possible ($a == $b) - it doesn't get better than that.
Because of the problem I just explained, I have considered prior to comparison, performing some quick cleanup. Such as removing slashes from the path and leading or trailing whitespace. Can you think of any gotcha's with this technique?
The reason I ask is, I am implemening a quick reverse-recursive globbing function, but for security reasons I never want it to travel outide the docroot, for this I need a accurate (bug free implementation) of path comparison.
Any opinions, suggestions, etc?
Cheers