<?php
$p = fopen("test.txt", "r");
while(!feof($p))
{ $output = htmlspecialchars(fgets($p, 4096));
$output = preg_replace("/((http(s?):\/\/)|(www\.))([\w\.]+)/i", "<a href=\"http$3://$4$5\" target=\"_blank\">$2$4$5</a>", $output);
print $output;
}
fclose($p);
?>
<?php
$p = fopen("test.txt", "r");
while(!feof($p))
{
$output = htmlspecialchars(fgets($p, 4096));
$output = preg_replace("/((http(s?):\\\/\\\/)|(www\\\.))([\\\w\\\.]+)/i", "<a href=\"http$3://$4$5\" target=\"_blank\">$2$4$5</a>", $output);
print $output;
}
fclose($p);
?>
Originally posted by thebear
yeah, that works
the only problem is on URLs that have a / after the .com, it doesnt add it...(ex. http://site.com/page.php)