i'm using jquery to output the results of a json string created by php from a database,
the only problem is, that some of the data is on multiple lines... how would i get around this causing a unterminated string literal error in javascript?
i'm using jquery to output the results of a json string created by php from a database,
the only problem is, that some of the data is on multiple lines... how would i get around this causing a unterminated string literal error in javascript?
Escape line endings by replacing "\n" with "\\n" and "\r" with "\\r". You will also want to escape single or double quotes, depending on which you are using to delimit the string.
The following code will get rid of all \r and \n characters.
preg_replace('/[\r\n]+/', "", $stringFromDB)