Page 1 of 1

[SOLVED] Format Text

Posted: Fri Oct 08, 2004 8:40 am
by AliasBDI
I am pulling a record from a database which looks like this:
John jumped over the moon.

John tripped when landing.
When I echo this result it looks like this:
John jumped over the moon. John tripped when landing.
I was wondering if there was a way for PHP to treat the returns in the record as <br> tags or hard returns in HTML. I didn't want to have to go and place <br> tags in the records. Here is my echo:

Code: Select all

<?php
echo $row_detailsArticle['content']; 
?>

Posted: Fri Oct 08, 2004 8:45 am
by malcolmboston
nl2br

when inserting into the database use this to detect line breaks in textfields

Code: Select all

$text = nl2br($text)
hten when it is retrieved it will format it in the way you describe

Posted: Fri Oct 08, 2004 8:51 am
by AliasBDI
Perfect. Thanks!

Posted: Fri Oct 08, 2004 8:52 am
by malcolmboston
no problem