note 12278 deleted from ref.strings by sander

From: Date: Sun, 07 Apr 2002 13:39:11 +0000
Subject: note 12278 deleted from ref.strings by sander
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-28921@lists.php.net to get a copy of this message
Here's my version of the "urls_clickable" function mentioned several times above. This one adds the "<a href" tags around URL's (incl https://) as well as e-mail addys. function HTMLEncode($text) { $searcharray = array( "'([-_\w\d.]+@[-_\w\d.]+)'", "'(?:(?!://).{3}|^.{0,2})(www\.[-\d\w\.\/]+)'", "'(http[s]?:\/\/[-_~\w\d\.\/]+)'"); $replacearray = array( "<a href=\"mailto:\\1\">\\1</a>", "http://\\1", "<a href=\"\\1\">\\1</a>"); return nl2br(preg_replace($searcharray, $replacearray, stripslashes($text) )); } ...works for me!

« previous php.notes (#28921) next »