note 15863 added to function.preg-replace

From: Date: Fri, 05 Oct 2001 19:02:28 +0000
Subject: note 15863 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-18614@lists.php.net to get a copy of this message
To use custom URL tags, so you can disallow the rest of the html tags (using htmlspecialchars() or htmlentities()), I wrote the following: $pattern = "/(\[URL=\\\\\")(.*?)(\\\\\"\])/i"; $replace = "<a href=\"\\2\">"; $String = preg_replace($pattern, $replace, $String); $String = eregi_replace("(\[/URL\]){1}", "</a>", $String); this will replace [url="http://www.something.com"]Something.com[/url] with <a href="http://www.something.com">Something.com</a> -- http://www.php.net/manual/en/function.preg-replace.php http://master.php.net/manage/user-notes.php?action=edit+15863 http://master.php.net/manage/user-notes.php?action=delete+15863 http://master.php.net/manage/user-notes.php?action=reject+15863

« previous php.notes (#18614) next »