Gibbs Posted January 16, 2007 Share Posted January 16, 2007 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 Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 16, 2007 Share Posted January 16, 2007 you'd have to do [img]http://image[/img]<br />[b]Text 1[/b] Text2not [img]http://image[/img]<br />[b]Text 1[/b] Text2There's a NL in there, plus an existing BR. So, you get two BRs. That IS what you've asked for. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 16, 2007 Share Posted January 16, 2007 Gah. Stupid code.Do this:[code][img]image[/img]<br />[b]Text 1[/b] Text2[/code] or this:[code][img]image[/img][b]Text 1[/b] Text2[/code] Quote Link to comment Share on other sites More sharing options...
Gibbs Posted January 16, 2007 Author Share Posted January 16, 2007 Thanks for your reply but it didn't help.Whenever I hit "Update Page" on my editor WITHOUT editing or touching it new breaks are added each time... Quote Link to comment Share on other sites More sharing options...
obsidian Posted January 16, 2007 Share Posted January 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
Gibbs Posted January 16, 2007 Author Share Posted January 16, 2007 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 Quote Link to comment Share on other sites More sharing options...
Gibbs Posted January 16, 2007 Author Share Posted January 16, 2007 Ops double post Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.