Click to See Complete Forum and Search --> : Convert [b][/b] to <b></b>


Dysan
03-31-2008, 10:17 AM
Hi,

I have a textbox within a form, that contains the following:

[ b ]This is bold text[ /b ]

Upon submitting the form, how do I convert the [ b ] tags into <b></b> tags, to display all the text bold? - Like below?

This is bold text

scragar
03-31-2008, 10:27 AM
$str = preg_replace("/\[b\](..*?)\[\/b\]/", "<strong>\\1</strong>", $str);

untested.

Dysan
03-31-2008, 10:40 AM
How would I retrieve the data from a textbox. e.g. "This text is bold"

MrCoder
03-31-2008, 11:21 AM
Your looking for this? (http://en.wikipedia.org/wiki/BBCode)

Dysan
03-31-2008, 01:01 PM
Yes