PHP is echoing JavaScript (I’m using the jQuery library) something like this:
echo 'var users = $("#add").val().split("\n");';
However, the \n is creating a line break in what the echoed script looks like, and therefore breaking the JavaScript. Is there a way to circumvent this?
Many thanks!
The
\nis an escape sequence meaning newline. Backslashes are the beginning of escape sequences, to output a backslash then write\\. So you want\\n. Other useful escape sequences include the quote: use\"to put a quote into the string instead of ending the string.