Jump to content

nl2br keeps writing new <br/> tags


Gibbs

Recommended Posts

I currently have two functions that convert bb to html and vice verse. At the bottom of these two functions I am using:
[code]$string = nl2br($string);[/code]

When I write new code via my editor I have created it keeps adding more <br/> tags I haven't asked for.

For example this

[code][img]image[/img]<br />
[b]Text 1[/b] Text2[/code]

Changes to this

[code][img]image[/img]<br /><br />
[b]Text 1[/b] Text2 <br />[/code]

Is there a way to stop it writting more <br/> tags?

Thanks
Link to comment
https://forums.phpfreaks.com/topic/34434-nl2br-keeps-writing-new-tags/
Share on other sites

In addition to jesirose's explanation, I would challenge you to consider [b]when[/b] you are running your parser. If you run your parser when you [i]output[/i] your code, you should be fine; however, if you run your parser on it when your [i]input[/i] the code, it will be saved with the new tags [b]and[/b] the line breaks in there, so every time you edit it, you'll have another BR tag added on.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.