I use jquery to output the results of a json string created by php from a database,
The only problem is that some data is on multiple lines ... how would I get around this, which will result in a line break error in javascript?
Ends the Escape line, replacing "\ n" with "\\ n" and "\ r" with "\\ r". You will also want to avoid single or double quotes, depending on what you use to separate the lines.
The following code will get rid of all the characters \ r and \ n.
preg_replace('/[\r\n]+/', "", $stringFromDB)