How To Escape Newlines In PHP For Javascript
erics, Posted January 11th, 2012 at 7:39:54pm
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); |
Leave Your Comment
All fields marked with "*" are required.