Run htmlspecialchars & Leave HTML Alone?
| From: | Waldo Jaquith | Date: | Mon, 02 Apr 2001 20:32:21 +0000 |
| Subject: | Run htmlspecialchars & Leave HTML Alone? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-46679@lists.php.net to get a copy of this message | ||
Folks,
I'm looking for a function that will convert all HTML special characters
(ie, everything converted by htmlspecialchars()) but leave HTML alone.
Consider the following example:
Perhaps their greatest release is "Times & Changes," which sold over
3,000,000 copies, according to <A HREF="http://www.billboard.com/">.
This should be echoed as:
Perhaps their greatest release is "Times & Changes," which
sold over 3,000,000 copies, according to <A
HREF="http://www.billboard.com/charts/?op=view&name=Before+These+Crowded+Str
eets">.
That is, it leaves alone anything anything within <> tags, but everything
else gets converted. I assume that this is a relatively simply
preg_replace, but I'm having a bad regex week, so I thought I'd see if
anybody else had written this already. :) Thanks, all.
Best,
Waldo