note 42824 deleted from function.preg-replace by betz

From: Date: Thu, 26 Aug 2004 09:16:20 +0000
Subject: note 42824 deleted from function.preg-replace by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75306@lists.php.net to get a copy of this message
Note Submitter: Kyle Barrow ---- Yet another simple URL link maker. This one ignores any period at the end of the URL which is usually a good thing: <?php function MakeUrl($strUrl) { $strUrl = preg_replace("/(http(s)?:\/\/[^\s\\n]*)\\b(\/)?/i","<a href=\"\\0\">\\0</a>",$strUrl); return $strUrl; } MakeUrl("Blah, blah, http://php.net/."); // result: "Blah, blah, <a href="http://php.net/">http://php.net/</a>." ?>

« previous php.notes (#75306) next »