Jump to content

BBCode


kevinritt

Recommended Posts

I've set up a page where the client can edit text from a database using a form. After the form is submitted, the text is updated. I'd like to add BBCode to the textarea (similar to what I'm typing in now  :-[) so the client can change colors, fonts, size, etc. How can I do this? Is there a tutorial out there?

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

<?php
$string = "<table><tr><td>I [i]am[/i] so [b]cool[/b]</td><td>[smile]</td> </td><tr></table>";

$bb_replace = array('[b]','[/b]','[i]','[/i]','[smile]');

$bb_replacements = array ('<b>','</b>','<i>','</i>','<img width="50px" height="30px" src="http://tbn2.google.com/images?q=tbn:kq6ay2cATrQg0M:http://www.teacherjoe.com/smiley2.gif">',' ');

$string = str_replace($bb_replace,$bb_replacements,$string);

echo $string;
?>

 

Link to comment
https://forums.phpfreaks.com/topic/138280-bbcode/#findComment-722982
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.