basta cosi


se html
$var=str_replace("\r\n","
",$var);



se js
$var=str_replace("\r\n","\\r\\n",$var);