Jump to content

Bit of a Dilemna with bbCode and htmlentities


ShoeLace1291

Recommended Posts

I have written a page for my website that displays tutorials.  The user uses bb code such as [example] and such so there is no html needed to write it.  On the page that displays the tutorials, I have to use htmlentities so that if a user attempts to insert html into the tutorial, it just displays raw text.  The only problem is that it also displays the bbcode as raw text since i use str_replace to replace the bbcode with the html tags.  Is there a way to use htmlentities only with html that wasn't a bbcode?

I'm not really sure how I'm supposed to do this...  This is my code:

$bbcode = array('[p]', '[/p]', '[example]', '[/example]');
		$replacewith = array('<p>', '</p>', "<div id='example'>", '</div>');

		$tutContent = str_replace($bbcode,$replacewith,$tutContent);
		$tutContent = htmlentities($tutContent);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.