[In my answer, I'm going to be very explicit with my use of single- and double-quotes.]
Your problem is because of PHP's string-interpolation rules.
In PHP, "\n" and '\n' are not the same thing.
"\n" is the single newline character, because escaped characters are interpolated inside double-quoted string literals in PHP.
'\n' is the literal string "<backslash>n" (two characters), because escaped characters are
not interpolated inside single quotes in PHP.
In your invocation of str_replace(), you use '\n' as your "search-for" string, so you're telling PHP to look for "<backslash>n" in the string "Success<newline><newline>".
'<backslash>n' does not appear in "Success<newline><newline>". '<backslash>n<backslash>n', however, does appear twice in 'Success<backslash>n<backslash>n'.
I would also like to draw your attention to the special-purpose PHP builtin function, nl2br() (
It's designed to do what you're doing right now.
Want the best answers? Ask the best questions: TANSTAAFL!!