How To Escape Newlines In PHP For Javascript
erics, January 11th, 2012
You must use all three lines together for it to work…YMMV:
1 2 3 |
$escaped = str_replace(chr(10),'\n',$original_value); $escaped = str_replace(chr(13),'\r',$escaped); $escaped = preg_replace("/(\r?\n)/","\n",$escaped); |