php, newlines and javascript arrays

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

php, newlines and javascript arrays

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
Post Reply