strip_tags and nl2br

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey everyone,

I have a little bit of a quandry. I need to strip HTML tags from user input, but I also need to convert \n's from the textarea elements to <br> tags so it will display properly in a browser.

nl2br() works just fine, but if I use strip_tags first, then run nl2br, nl2br won't work as expected. Instead, everything shows up on a single line.

I understand why it won't work if I place a call to nl2br inside a call to strip_tags, but strip_tags doesn't get rid of \n's, right?

I'm making my calls like this:

$string = strip_tags($_SESSION['variable']);
$string = nl2br($string);

I would expect that to work, but it doesn't :( Am I missing something? I originally placed the call to strip_tags inside the call to nl2br, but when that didn't work, I tried doing these calls separately.

Thanks!

James
--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

"When you do the common things in life in an uncommon way, you will command the attention of the world." --George Washington Carver

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux