On Monday, September 15, 2003, at 12:58 PM, John W. Holmes wrote:

Justin French wrote:

Hi all,
I need to convert some text from a database for presentation on screen... as per usual, characters like quotes and ampersands (&) are giving me grief. the obvious answer is to apply htmlspecialchars(), BUT this also converts all < and > into &lt; and &gt; signs, which destroys the html mark-up within the text.
Is there a non-tag equivalent of htmlspecialchars(), or do I need to build one?

You'll have to build one.


If you know what characters are causing trouble, you could just use str_replace on them. Or you could use htmlspecialchars() and then run str_replace to convert &lt; and &gt; back into brackets.

Which is what I just did as a 'patch' :)



You could also use get_html_translation_table() to get the conversions, remove the < and > conversion elements of the array and then use strtr() to do the conversion.

I like that idea a LOT.


Thanks John!


Justin


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to