/ Published in: PHP

Returns the same string, except with links wrapped in <a href=""> tags. Works on www.snipplr.com and on http://snipplr.com
A variation of the script on the attached URL.
A variation of the script on the attached URL.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function activateLinks($string) { /* // This regular expression looks for <strong>http:// </strong>type url $string = preg_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="1" target=_blank>$0$1$2$3</a>', $string); // This regular expression looks for <strong>www. </strong>type url $string = preg_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '1<a href="http://2" target=_blank>$0$1$2$3</a>', $string); // This regular expression looks for <strong>[email protected]</strong> $string = preg_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '<a href="mailto:1" target=_blank>$0$1$2$3</a>', $string); */ if ($m) { $links=$match[0]; for ($j=0;$j<$m;$j++) { } } if ($m) { $links=$match[0]; for ($j=0;$j<$m;$j++) { } } return $string; }
URL: http://www.php.net/manual/en/function.preg-match-all.php#103552
Comments
