$string = "foo\r\nbar"; $string = addslashes($string); echo $string; $string = stripslashes($string); $string = nl2br($string); echo $string;