note 61249 deleted from function.preg-replace by nlopess
| From: | nlopess@php.net | Date: | Sun, 29 Jan 2006 22:14:16 +0000 |
| Subject: | note 61249 deleted from function.preg-replace by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-102693@lists.php.net to get a copy of this message | ||
Note Submitter: Marcus
Reason: useless
----
To display all code within 2 tags (even custom ones) to the user, you can use the following:
<?php
$text = preg_replace("/<code>(.*)<\/code>/e"
,'"<code>".htmlspecialchars("$1")."</code>"' ,
$text);
?>
Here it will convert all characters within the "<code>" tags to entities that the
user will see rather than have it formated by the browser. Useful for displaying code in articles
etc.
- http://www.marcusnoble.co.uk