ShoeLace1291 Posted October 15, 2007 Share Posted October 15, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/73376-bit-of-a-dilemna-with-bbcode-and-htmlentities/ Share on other sites More sharing options...
darkfreaks Posted October 15, 2007 Share Posted October 15, 2007 <?php $string=strip_tags($string, '<allowed html tag> [allowed bb code tag]');?> Quote Link to comment https://forums.phpfreaks.com/topic/73376-bit-of-a-dilemna-with-bbcode-and-htmlentities/#findComment-370216 Share on other sites More sharing options...
ShoeLace1291 Posted October 16, 2007 Author Share Posted October 16, 2007 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); Quote Link to comment https://forums.phpfreaks.com/topic/73376-bit-of-a-dilemna-with-bbcode-and-htmlentities/#findComment-370303 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.