DanDaBeginner Posted April 13, 2007 Share Posted April 13, 2007 I not sure if bbcode was the term for this.. how this can be done? for example in this forum, with the open and closing some code here or [/img]link of image here[/img] and on the display it is display with a ceratin CSS/format or something..is this can be done through "eregular expression"? and before saving on the dbase [/img] is converted to <img src"" />? am I right? is there a string function in PHP to make the searching of tags easy? all I need is the concept thanx.. Quote Link to comment https://forums.phpfreaks.com/topic/46842-solved-how-was-bbcode-done/ Share on other sites More sharing options...
Guest prozente Posted April 13, 2007 Share Posted April 13, 2007 <?php $data = 'testing [img=link of image here] and [img=http://www.example.com/1.jpg]'; echo preg_replace('#\[img\](.*)\[/img\]#iU', '<img src="\\1">' ,$data); ?> Quote Link to comment https://forums.phpfreaks.com/topic/46842-solved-how-was-bbcode-done/#findComment-228322 Share on other sites More sharing options...
wildteen88 Posted April 13, 2007 Share Posted April 13, 2007 yes bbcode is done by regular expressions (regex for short). When doing BBCode parsing don't parse the BBCodes when it goes into the database. Instead only parse when you go to display the data on the web page. This way it makes editing the content whole lot easier. If you parsed the BBCodes when you inserted it in to the database then when you go to edit it you will have convert the HTML back in to BBCode format in order to edit it. It is always best to put data in to the database in it's rawest format. Also you should only format the data how you want it when you go to display it. Quote Link to comment https://forums.phpfreaks.com/topic/46842-solved-how-was-bbcode-done/#findComment-228832 Share on other sites More sharing options...
DanDaBeginner Posted April 14, 2007 Author Share Posted April 14, 2007 thanx guys.. what a wonderful suggestion wildteen.. Quote Link to comment https://forums.phpfreaks.com/topic/46842-solved-how-was-bbcode-done/#findComment-229070 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.