RedCoupe

PHP replace crlf in a textarea with br

by on Sep.09, 2010, under Web design / development

I had a textarea value which was obtained from a MySQL database and it contained many instances of crlf or \n. To display correctly on a web page I wanted to convert those to <br /> so I used the following code:

<?php echo nl2br($myrecorsetvalue); ?>

Obviously you would need to replace the $myrecorsetvalue with whatever recordset variable you are using.

:,

Leave a Reply

You must be logged in to post a comment.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!