LemonInflux Posted October 7, 2007 Share Posted October 7, 2007 No, not PHP or HTML or whatever. BBCode. What I want to know, is whether PHP can go through a written piece of text, count the number of times something is entered (say, ), and the number of times something else is entered (). Then, if there are more of the first than the second, keep adding the second one on the end until they're equal. Alternatively, is there a way to allow bbc to be used, but if a tag isn't closed, it won't affect the rest of the page? Quote Link to comment https://forums.phpfreaks.com/topic/72179-auto-close-tags/ Share on other sites More sharing options...
Wuhtzu Posted October 7, 2007 Share Posted October 7, 2007 You would simply search for pairs using your regex so only if they have a proper opening and closing tag they will be replaced with real html: [tag]Some text[/tag] will be replaced with <tag>Some text</tag> [tag]Some text will not be replaced with <tag>Some text since it is missing a closing tag Then it's up to you if the users improper syntax should be shown or removed. When doing bbcode stuff it's a bad idea to simple search for [tag] and replace with <tab> and afterwards search for [/tag] and replace with </tag>... always search for pairs of opening and closing tags Maybe have a look at this tutorial: http://www.phpfreaks.com/tutorials/141/0.php I know it's done with searching for pairs and the problem with non-closed tags have been taken care of Quote Link to comment https://forums.phpfreaks.com/topic/72179-auto-close-tags/#findComment-363971 Share on other sites More sharing options...
LemonInflux Posted October 7, 2007 Author Share Posted October 7, 2007 http://reflexprojects.net/dav/functions/test.php o_O Quote Link to comment https://forums.phpfreaks.com/topic/72179-auto-close-tags/#findComment-364003 Share on other sites More sharing options...
LemonInflux Posted October 7, 2007 Author Share Posted October 7, 2007 I don't think the code worked.. Quote Link to comment https://forums.phpfreaks.com/topic/72179-auto-close-tags/#findComment-364008 Share on other sites More sharing options...
Aureole Posted October 11, 2007 Share Posted October 11, 2007 Lmao @ what happens when I go to that page and hit "Parse text"... you might wanna restrict access to that it's probably a neat way to DOS your site... it's also great for crashing my Browser, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/72179-auto-close-tags/#findComment-366829 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.