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.

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.


-- ---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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



Reply via email to