note 94549 deleted from function.htmlentities by danbrown

From: 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 &lt; 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 &lt;. I found this works: <?php $post = htmlentities($post, ENT_NOQUOTES); $post = preg_replace('/&lt;(.+?)&gt;/', '<$1>', $post); ?>

« previous php.notes (#162765) next »