There's another snippet on here that always comes up on google for finding the relative path to the root, but it doesn't work very well. This version will work from the root, from any subdirectory, and with malformed path names such as www.example.com/////dir////path///file.php
What I have here is designed to be pasted at the top of a php file, but you can also stick it inside a function and return $relpath.
CommentsSubscribe to comments
You need to login to post a comment.