I try to avoid asking stupid questions, but for some reason this just doesn't work. I am extracting some text from the database, including newlines. When using echo directly, this is the result:
=== BOLD TEXT ===\nHere is some text.
Here is how I extracted it:
$row = $query->row(); $content=$row->course_content;
None of the following has any effect .....
$content= str_replace(array("\r\n", "\r", "\n"), "<br />", $content); $content= str_replace("\n", " ", $content); $content = nl2br($content);
HOWEVER, when I hardcode it in a string to the original statement,
$content="=== BOLD TEXT ===\nHere is some text.";
Pang! it works ... any ideas as to why it refuses to accept database input, but ok with the manual string?
Code:
//Switch between these two: $row = $query->row(); $content=$row->course_content; $content="=== BOLD TEXT ===\nHere is some text."; $content = str_replace(array("\r\n", "\r", "\n"), "<br />", $content); $content = str_replace("\n", " ", $content); $content = nl2br($content); echo $content;