3v4l.org

run code in 300+ PHP versions simultaneously
<?php function absolute_path($base, $relative) { list($stack, $parts) = [explode('/', $base), explode('/', $relative)]; array_pop($stack); for ($i = 0; $i < count($parts); $i++) { if ($parts[$i] == '') continue; elseif ($parts[$i] == '..') array_pop($stack); else array_push($stack, $parts[$i]); } return join('/', $stack); } echo absolute_path( 'http://mhelper.ru/project/dev/works/ElenaBeauty/index.html', '../../css/reset.css' );
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.26, 7.4.0 - 7.4.13, 8.0.0 - 8.0.2
http://mhelper.ru/project/dev/css/reset.css