PHP - 删除字符并连接另一个字符的函数(也称为相对于绝对URL的转换)

I have a phpbb external script which outputs a relative url

(like ./forum/viewtopic.php?f=xx&t=xx),

but for making an rss feed I need the absolute url

(http://example.com/forum/viewtopic.php?f=xx&t=xx) to use.

My question is: How could I make this?

I suppose it should just be a string function, to replace the first dot and then concatenate the http://example.com before it, but I don't have enough php skills to do that.

Simply replace your ./ with the hostname.

$url = str_replace('./', 'http://example.com/', $url);