note 94549 deleted from function.htmlentities by danbrown
| From: | danbrown@php.net | Date: | Wed, 11 Nov 2009 16:04:32 +0000 |
| Subject: | note 94549 deleted from function.htmlentities by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162765@lists.php.net to get a copy of this message | ||
Note Submitter: Jach
----
In response to a previous poster, I was looking for something slightly different. I have a blog, and
as an admin I want to type code snippets, but I want to type "x < 3" instead of "x
< 3", but I also want to type raw HTML. So I could do "<b>x</b> <
3" and expect x to be bolded but the < to be converted to <. I found this works:
<?php
$post = htmlentities($post, ENT_NOQUOTES);
$post = preg_replace('/<(.+?)>/', '<$1>', $post);
?>