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. Link to comment https://forums.phpfreaks.com/topic/238050-containing-html-tags-inside-a-div/ 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... Link to comment https://forums.phpfreaks.com/topic/238050-containing-html-tags-inside-a-div/#findComment-1223272 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? Link to comment https://forums.phpfreaks.com/topic/238050-containing-html-tags-inside-a-div/#findComment-1223274 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. Link to comment https://forums.phpfreaks.com/topic/238050-containing-html-tags-inside-a-div/#findComment-1223283 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 Link to comment https://forums.phpfreaks.com/topic/238050-containing-html-tags-inside-a-div/#findComment-1225039 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.