Jump to content

BB Code help?


bravo81

Recommended Posts

Hi guys,

 

Im trying to replace certain bits of text that is displayed from the database $fetch->quote to allow BB Codes.

 

So if they enter

into the quote, it will output <center>

 

Can someone help me please? i have a file that i was told should do it, but i dont see how it works as nothing is assigned to $txt ...


<?
function replace($txt) {


$txt = str_replace(":sup:", "<img src=\"../images/smiles/thumbsup.gif\">", $txt);
return $txt;
?>

 

Ive tried a few different ways to do this, and used before coming here google but no dice.

 

Any help would be appreciated.

 

Regards,

 

~Bravo81

Link to comment
https://forums.phpfreaks.com/topic/74037-bb-code-help/
Share on other sites

Use str_replace() to replace text:

 

$txt = str_replace('
[center]', '<center>', $txt);
$txt = str_replace('[/center]
', '</center>', $txt);

 

The reason that code you pasted doesn't assign anything to $txt is because it's a function. If you don't know about functions you should go learn about them.

Link to comment
https://forums.phpfreaks.com/topic/74037-bb-code-help/#findComment-373841
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.