1 2 3 4 5 6 7 8 9 10 11 12 13
| <?php function replace_url ($content) { if (empty($content)) return;
$preg = '/(?:http:\/\/)?([\w.]+[\w\/]*\.[\w.]+[\w\/]*\??[\w=\&\+\%]*)/is'; $content = preg_replace($preg, '<a href="http://\1" target="_blank">\1</a>', $content);
return $content; }
echo replace_url('百度:http://blog.csdn.net/moqiang02'); ?>
|