<?php
$txt = "This is a link to http://www.google.com/";
$pattern1 = '/http:\/\/(.*)\//';
$pattern2 = '/http:\/\/(.*)\//e';
$replacement1 = "<a href='$0'>$1</a>";
$replacement2 = 'strtoupper("<a href=\'$0\'>$1</a>")';
echo preg_replace($pattern1, $replacement1, $txt);
//This is a link to <a href='http://www.google.com/'>www.google.com</a>
echo "<br />";
echo preg_replace($pattern2, $replacement2, $txt);
//This is a link to <A HREF='HTTP://WWW.GOOGLE.COM/'>WWW.GOOGLE.COM</A>
?>