I have searched throughout this site and google, and could not find a viable solution. There are solutions, but none seem to work for me.
I have a text area that serves as the input for a form, as well as the output (editable) when displaying the form to edit. So, I have a textarea like so:
This is a
This is a\\r\\n\\r\\ntest.
$resolution = stripslashes($resolution);
This is a\r\n\r\ntest.
$resolution = trim($resolution);
$resolution = nl2br($resolution);
$resolution = htmlentities($resolution);
$resolution = preg_replace("\\r\\n","<br>",$resolution);
PHP has two different string building modes. The first uses single quotes, and will do absolutely no variable or special character substitutions. That's what you're using.
The second is variable-embedding in double quoted strings, which should work:
$text = str_replace("\\", "\", $text); echo "<textarea>$text</textarea>";
\n should now be active carriage return and newline characters in your output, not the character "slash" and then an 'r' or 'n'