Jump to content

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);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.