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 Link to comment https://forums.phpfreaks.com/topic/34434-nl2br-keeps-writing-new-tags/ 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. Link to comment https://forums.phpfreaks.com/topic/34434-nl2br-keeps-writing-new-tags/#findComment-162142 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] Link to comment https://forums.phpfreaks.com/topic/34434-nl2br-keeps-writing-new-tags/#findComment-162144 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... Link to comment https://forums.phpfreaks.com/topic/34434-nl2br-keeps-writing-new-tags/#findComment-162154 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. Link to comment https://forums.phpfreaks.com/topic/34434-nl2br-keeps-writing-new-tags/#findComment-162157 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 Link to comment https://forums.phpfreaks.com/topic/34434-nl2br-keeps-writing-new-tags/#findComment-162185 Share on other sites More sharing options...
Gibbs Posted January 16, 2007 Author Share Posted January 16, 2007 Ops double post Link to comment https://forums.phpfreaks.com/topic/34434-nl2br-keeps-writing-new-tags/#findComment-162189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.