Jump to content

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

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.