Well, assuming this is a simple directory problem, the browser will access "/html/foo/this/../" as "/html/foo/". That's the easiest way and requires no scripting at all. Magical, eh? If that's too simple for you, you can use explode($string,"/") to get each part in an array, delete the last array element, and then use implode() to stick them together again.