faqts : Computers : Programming : Languages : PHP : Common Problems : Regular Expressions

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 20 people (85%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

How can I replace returns with <br>s?

Mar 15th, 2002 16:48
Jessi Conrad, Nathan Wallace, Jason Brooke


Use nl2br();

http://www.php.net/manual/function.nl2br.php3


To make the changes to the text itself you can use:

$text = str_replace("\n","<br>",$text);