bravo81 Posted October 20, 2007 Share Posted October 20, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/74037-bb-code-help/ Share on other sites More sharing options...
redarrow Posted October 20, 2007 Share Posted October 20, 2007 dont understand you, So sorry tell me agin slowly with loads off deatal...... Quote Link to comment https://forums.phpfreaks.com/topic/74037-bb-code-help/#findComment-373820 Share on other sites More sharing options...
Jeremysr Posted October 20, 2007 Share Posted October 20, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/74037-bb-code-help/#findComment-373841 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.