Jump to content

PHP BBCode


The Little Guy

Recommended Posts

I can not get this function to work:

 

function bbcode2html($strInput) {
return preg_replace('/\\[php\\]/i', '/\\[\/php\\]/i',highlight_string($strInput),$strInput);
}

 

It highlights the correct string, but it doesn't remove the bbcode tags, and it adds 1 to the end of every string. I don't know what is wrong.

Link to comment
https://forums.phpfreaks.com/topic/38389-php-bbcode/
Share on other sites

This works:

 

<?php
function bbcode($s)
{
   $s = str_replace("]\n", "]", $s);
   $match = array('#\[php\](.*?)\[\/php\]#se');
   $replace = array("'<div>'.highlight_string(stripslashes('$1'), true).'</div>'");
   return preg_replace($match, $replace, $s);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/38389-php-bbcode/#findComment-184220
Share on other sites

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.