RE: [PHP] Htmlentities and Newlines?
| From: | John W. Holmes | Date: | Sat, 28 Sep 2002 19:30:33 +0000 |
| Subject: | RE: [PHP] Htmlentities and Newlines? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117972@lists.php.net to get a copy of this message | ||
> Perhaps I don't understand the use of 'htmlentities' too well, but I
would
> like newlines to be retained/inserted into a db, and then if
displayed, to
> produce a new line from a textarea. However, I want the possibility of
> dangerous html excluded (hence the use of 'htmlentities').
>
> Is there some way of excluding '\n \r ' and other newline indicators
from
> 'htmlentities()'? Perhaps a combination of preg_match and something
else?
> I'm
> a bit brained-fried struggling with other errant parts of this code
since
> 6
> am.
> Any ideas how I could proceed?
What's wrong with
echo nl2br(htmlentities($text));
??
---John Holmes...