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
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.
Link to comment
Share on other sites

Ah thanks. The reason was that the <br/> tags got added, as told to, but on opening the file it added new ones as the old ones were only being displayed.

Difficult to explain. Your replies helped a lot though.

Thank you jesirose and obsidian  ;D
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.