php regex [b] to

There are various BBCode parsers available for PHP, for instance

which allows you to simply define your replacement rules by hand:

echo bbcode_parse(
    bbcode_create(
        array(
            'b' => array(
                'type'      => BBCODE_TYPE_NOARG,
                'open_tag'  => '<b>',
                'close_tag' => '</b>'
            )
        )
    ),
    '[b]Bold Text[/b]'
);
// prints <b>Bold Text</b>

Also check the various similar questions about BBCode Parsers:

Leave a Comment