I am building multi-line strings in PHP that need to be used in Javascript functions, so I echo out the strings and they appear where they should, but the problem I’m having is that Javascript multi-line strings must have a backslash \ at the end of each line.
Aside from hard-coding the backslashes in (which I can’t do since the strings are used outside of the Javascript functions, too) how can I add a backslash before each line break in the string?
1 Answer