Is there an inbuilt way in PHP to parse a string like this: '/path/to/../../up/something.txt'

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-02-26T01:20:37Z Indexed on 2010/03/29 0:43 UTC
Read the original article Hit count: 370

So say I have a string like so of a path

$path = '/path/to/../../up/something.txt';

Is there a way built into PHP to parse it and come up with a URL without the directory ups (../) ?

E.g.

$path = parsePath('/path/to/../../up/something.txt'); // /up/something.txt

© Stack Overflow or respective owner

Related posts about php

Related posts about directory-structure