Re: htmlentities -- can it skip tags
| From: | John W. Holmes | Date: | Mon, 15 Sep 2003 02:58:26 +0000 |
| Subject: | Re: htmlentities -- can it skip tags | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-162592@lists.php.net to get a copy of this message | ||
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 < and > 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 < and > 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