Code:
<html>
<head>
<title>Test</title>
</head>
<body>
<?php
$t = "hey das is a coole seite http://www.xxx.com/ <-- schauts euch das an";
echo preg_replace( "/((www\.|http:\/\/).*?)\s/", "<a href=\"$1\" target=\"_new\">$1</a> ", $t) . "
\n";
$t = "hey das is a coole seite www.xxx.com <-- schauts euch das an";
echo preg_replace( "/((www\.|http:\/\/).*?)\s/", "<a href=\"$1\" target=\"_new\">$1</a> ", $t) . "
\n";
?>
</body>
</html>
Einzige Bedingung: Dei URL muss durch einen Blank, Tab, etc. an Ende vom Text getrennt sein.