Resolve a relative path in a URL with PHP
Example 1: domain.com/dir_1/dir_2/dir_3/./../../../ Should resolve naturally in the browser into = domain.com/ Example 2: domain.com/dir_1/dir_2/dir_3/./../../../test/././../new_dir/ Should resolve into domain.com/new_dir/ Example 3: domain.com/dir_1/dir_2/dir_3/./../../../test/dir4/../final Should resolve into domain.com/test/final How can I iterate through the string to do this? I feel like the for() loop would get confused at this point. The answers provided in Transform relative path into absolute URL using PHP and PHP: How to resolve a relative url don't work for me in this case. I