Striping Slashes from form submission

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

AFAIK, and from the php manual:
php docs wrote:nl2br -- Inserts HTML line breaks before all newlines in a string
so removing the HTML line breaks it's put in shouldn't affect the newlines.

Mac
User avatar
gite_ashish
Forum Contributor
Posts: 118
Joined: Sat Aug 31, 2002 11:38 am
Location: India

Post by gite_ashish »

from php man:
Note: Starting with PHP 4.0.5, nl2br() is now XHTML compliant. All versions before 4.0.5 will return string with '<br>' inserted before newlines instead of '<br />'.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Code: Select all

&lt;?php
str_replace("&lt;br /&gt;","\n",$string);
?&gt;
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Takuma wrote:

Code: Select all

&lt;?php
str_replace("&lt;br /&gt;","\n",$string);
?&gt;
Then you'll end up with double newlines because nl2br() doesn't replace the newlines it simply puts an HTML linebreak in front of them.

Mac
Post Reply