Hi Kasper,
Just trying here. It\'s only my 3rd day as a php progger, so forgive me if this is too long-winded or just plain buggy.
This script searches for http:// and uses everything from there to the next space as an URL. Of cource, you could also check for URLs starting with www. Also, if one ends with a punctuation mark or any other invalif character, it will be included in the URL, so \"Visit my site at http://www.goleztrol.nl!\" will result in an invalid URL.
Gr.
Jos
--- The script ---
$lastpos = strpos($text, \"http://\");
// Keep searching for http://
while ($lastpos > 0) :
// Add any \'normal\' text
$result .= substr($source, 1, $lastpos);
// Cut it from the source
$source = substr($source,$lastpos);
// Search for a space to mark the end of the url
$lastpos = strpos($source, \" \");
if ($lastpos){
// We found a space
$url = substr($source, 1, $lastpos);
$source = substr($source, $lastpos);
} else {
// No space. Rest of text is URL
$url = substr($source, 1);
$source = \"\";
};
// Add URL to result
$result .= \"<a href=\\"$url\\">$url</a>\";
// repeat search
$lastpos = strpos($text, \"http://\", $lastpos);
endwhile;