Page 1 of 1

php, newlines and javascript arrays

Posted: Wed Oct 09, 2002 6:51 pm
by phpScott
I am having trouble getting around new line characters. I store a textarea field into a db then pull it back out and into a javascript array along with other descriptions. However when some one puts a hard return into the textarea the db stores it fine but it kills my javasctipt array.
Any thoughts.

Posted: Wed Oct 09, 2002 7:02 pm
by volka
depends on what you want to do with the text.
i.e. with http://www.php.net/manual/en/function.str-replace.php you can get rid of the \r,\n signs or replace them by something appropriate.
there's also a function called nl2br() but it will not replace \r\n, it prepends a <br/> - probably not not solving your problem