The PHP function str_replace() is failing to work with the output from a mysqli_fetch_row() result.
Nah – you are failing to feed it the correct parameter :-)
Assuming
$row[1] = Hello \\r\\n This needs it's own line BOO.
If you actually have double backslashes in your data there, then you need to have the same amount of backslashes in your search expression as well.
Now do you? Let’s have a look:
str_replace('\\r\\n', '<br>', $row[1]);
Let’s take that first argument, and output it:
echo '\\r\\n';
Output: \r\n
– oops, just single backslashes …?
The backslash is the escape character, and to take that special meaning from it – even in single-quoted strings – another backslash is put in front of it. So what you have here, is the first backslash escaping the second one, therefor leaving you with one single backslash in your actual parsed text literal.
So you have to double those backslashes for them to actually mean “two literal backslashes”:
echo '\\\\r\\\\n';
Ah, that outputs \\r\\n
… ain’t that nice.
So, what you actually want to use for your replacing, is
str_replace('\\\\r\\\\n', '<br>', $row[1]);
(Using only three backslashes would work as well here, since the first one would mask the second then, and the third would be “stand-alone” and taken literally, because after it there is no character that has special meaning in a single-quoted string. But to avoid confusion – and just out of principle – it’s better to double them both.)