把http://开头的字符串转变成一个WEB连接

---摘自《php中文用户》

 <?
function parse_body($str="") {
$str_array = split (" ",$str);
$sz = sizeof ($str_array);

for ($i = 0; $i < $sz; $i++)
{
if (strstr($str_array[$i], "http://"))
$fr = sprintf ("%s <a href='%s'>%s</a>", $fr, $str_array[$i], $str_array[$i]);
else if (strstr($str_array[$i], "@"))
{
if (strstr($str_array[$i], "."))
$fr = sprintf ("%s <a href='mailto:%s'>%s</a>", $fr, $str_array[$i], $str_array[$i]);
else
$fr = sprintf ("%s %s", $fr, $str_array[$i]);
}
else
$fr = sprintf ("%s %s", $fr, $str_array[$i]);
}
return $fr;
}
?>
Use this function to parse a string for url or mailto addresses. If there is a @ sign and a . it replaces it with
mailt:(that string),
and also looks for http://

Use in the following format:
$new_str = parse_body($str);
echo("$str");