PHP / File Manipulation / Replace hard breaks
Snippet details
ID: 56
Viewed: 2814
Added: 2006-01-13
Version:
Sorry no demo
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.
nl2br doesn't always work if you submit html in a textarea.
General Details
Snippet uploaded by: snippet
Email : webmaster@snippetlibrary.com
Snippet By: snippet
<!---Head--->
none
<!---Body--->
<?
//replaces r or n with <br>
$something = str_replace("rn|r|n", "<br>", $something)
?>
Subject: nl2br
Comment By: Rob Geerts on Thu 12th of January 2006 07:20:50 PM
pffff why not use:
$something = nl2br($something);
$something = nl2br($something);
Subject: Re: nl2br
Comment By: snippet on Fri 13th of January 2006 02:12:30 AM
Hi,
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.
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.
