Not a Member Yet,
Click here to Register

ID: 56
Viewed: 11973
Added: Jan 12, 2006
Snippet uploaded by: snippet
Written By: snippet
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

this small code will replace hard break \n or \r to <br> so it shows up properly in the html document that is displayed.

nl2br doesn't always work if you submit html in a textarea.



//replaces r or n with <br>

$something = str_replace("\r\n|r|n", "<br>", $something)

Subject: nl2br
[ Reply ]
Comment By: Rob Geerts on 12th of January 2006 10:20 AM

pffff why not use:
$something = nl2br($something);

Subject: Re: nl2br
[ Reply ]
Comment By: snippet on 12th of January 2006 05:12 PM


there are some reasons why you can't use that. mainly if the webmaster has it set to submit html tags and such in a textarea the nl2br will not work correctly. So you have to follow that snippet of code.

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!