note 94549 added to function.htmlentities
| From: | Jach at osu1 dot php dot net | Date: | Wed, 11 Nov 2009 16:01:17 +0000 |
| Subject: | note 94549 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162764@lists.php.net to get a copy of this message | ||
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);
?>
----
Server IP: 208.69.120.35
Probable Submitter: 24.16.127.219
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- https://master.php.net/note/edit/94549
Del: integrated -- https://master.php.net/note/delete/94549/integrated
Del: useless -- https://master.php.net/note/delete/94549/useless
Del: bad code -- https://master.php.net/note/delete/94549/bad+code
Del: spam -- https://master.php.net/note/delete/94549/spam
Del: non-english -- https://master.php.net/note/delete/94549/non-english
Del: in docs -- https://master.php.net/note/delete/94549/in+docs
Del: other reasons-- https://master.php.net/note/delete/94549
Reject -- https://master.php.net/note/reject/94549
Search -- https://master.php.net/manage/user-notes.php