Sami Posted February 2, 2011 Share Posted February 2, 2011 How can I make my website support BB-codes? (Oops, I just tough I should look for any existing topics about this, but I can't find out how to delete this one) Link to comment Share on other sites More sharing options...
birbal Posted February 2, 2011 Share Posted February 2, 2011 bbcode or you can also write your own using preg_replace and regular expression Link to comment Share on other sites More sharing options...
Fmdpa Posted February 2, 2011 Share Posted February 2, 2011 An example: preg_replace('/\[b\](.*?)\[\/b\]/is', '<b>$1</b>', $txt); Notice how the square brackets are escaped. They normally contain a character class, but we want it to match the literal "[" character this time. "$1" represents the text within the parentheses in the regex.Tags like this are fairly simple to do, but image tags and similar tags are much more complex. The bbcode extension would be easier to use, but many hosts do not have it installed, nor would install it at your request. I was in your shoes once, and I checked with numerous hosts. None of them had the extension installed, and only a couple would install at your request. PEAR (a PHP library) has a class for it: http://pear.php.net/package/HTML_BBCodeParser Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.