protected function makeUriRelativeTo($uri, $root)
    {
        if (!$root) {
            return $uri;
        }

        if (is_array($uri)) {
            $uris = [];
            foreach ($uri as $u) {
                $uris[] = $this->makeUriRelativeTo($u, $root);
            }
            return $uris;
        }

        if (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri)) {
            return $uri;
        }
        return rtrim($root, '/') . "/$uri";
    }
protected function makeUriRelativeTo($uri, $root)
    {
        if (!$root) {
            return $uri;
        }

        if (is_array($uri)) {
            $uris = [];
            foreach ($uri as $u) {
                $uris[] = $this->makeUriRelativeTo($u, $root);
            }
            return $uris;
        }

        if (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri)) {
            return $uri;
        }
        return rtrim($root, '/') . "/$uri";
    }
protected function makeUriRelativeTo ( $ uri , $ root ) { if ( ! $ root ) { return $ uri ; } if ( is_array ( $ uri ) ) { $ uris = [ ] ; foreach ( $ uri as $ u ) { $ uris [ ] = $ this -> makeUriRelativeTo ( $ u , $ root ) ; } return $ uris ; } if ( substr ( $ uri , 0 , 1 ) === '/' || preg_match ( '/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/' , $ uri ) ) { return $ uri ; } return rtrim ( $ root , '/' ) . "/$uri" ; }
Makes a URI relative to another

@param string|array $uri
@param string $root
@return string
Makes a URI relative to another