src/Strings.php
public function relativeToAbsolute($string, $base)
    {
        $matches = preg_split('#(<(a|img)\b[^>]+>)#', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
        $old     = $matches;

        foreach ($matches as &$match) {
            if (preg_match('/<(a|img)\b/', $match) && !preg_match('/(?:http|#|mailto)/', $match)) {
                $match = preg_replace('/^([^"]+")([^"]+)/', '$1' . $base . '$2', $match);
            }
        }

        $string = str_replace($old, $matches, $string);
        return $string;
    }
public function relativeToAbsolute($string, $base)
    {
        $matches = preg_split('#(<(a|img)\b[^>]+>)#', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
        $old     = $matches;

        foreach ($matches as &$match) {
            if (preg_match('/<(a|img)\b/', $match) && !preg_match('/(?:http|#|mailto)/', $match)) {
                $match = preg_replace('/^([^"]+")([^"]+)/', '$1' . $base . '$2', $match);
            }
        }

        $string = str_replace($old, $matches, $string);
        return $string;
    }
public function relativeToAbsolute ( $ string , $ base ) { $ matches = preg_split ( '#(<(a|img)\b[^>]+>)#' , $ string , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ old = $ matches ; foreach ( $ matches as & $ match ) { if ( preg_match ( '/<(a|img)\b/' , $ match ) && ! preg_match ( '/(?:http|#|mailto)/' , $ match ) ) { $ match = preg_replace ( '/^([^"]+")([^"]+)/' , '$1' . $ base . '$2' , $ match ) ; } } $ string = str_replace ( $ old , $ matches , $ string ) ; return $ string ; }
Converts all relative hrefs and image srcs to absolute

@param string $string
@param string $base
@return string
Converts all relative hrefs and image srcs to absolute