Porl123 Posted June 1, 2011 Share Posted June 1, 2011 I have a forum where each user comment is contained inside its own div and I've noticed that if a user leaves a bb code (bold for example) open then it affects everything from that point on in the page. Is there a way to stop the html tag from leaking out into the page? If anyone knows a method or needs anymore information please just ask me. (: Thanks for your help. Quote Link to comment Share on other sites More sharing options...
requinix Posted June 1, 2011 Share Posted June 1, 2011 Replace the BBCode tags in pairs: each opening gets replaced with each closing. That means no dangling opening or closing HTML tags. Exactly how you do that depends on what method you use to do the replacement... Quote Link to comment Share on other sites More sharing options...
Porl123 Posted June 1, 2011 Author Share Posted June 1, 2011 I know this isn't the right section for this, but it's just a quick question. D: $content = preg_replace('/\[b\](.*?)(\[\/b\]|$)/i','<strong>\\1</strong>',$content); That's what I've replaced the individual open and close tags with. I want it to either match when it sees there's a [/b] or it reaches the end of the content. Although for some reason this doesn't seem to be matching when it reaches the end of the content, only when it identifies there's a [/b]. Do you know what I'm doing wrong? Quote Link to comment Share on other sites More sharing options...
Porl123 Posted June 1, 2011 Author Share Posted June 1, 2011 I'll use the right board. :] Cheers for your help. Quote Link to comment Share on other sites More sharing options...
Ollifi Posted June 4, 2011 Share Posted June 4, 2011 Also mark your post as solved if you don´t need more help 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.