Jump to content

[SOLVED] Converting [b] to html


smerny

Recommended Posts

Your best bet is regex if you want the tags to match.

 

$str = '[i]Hello [b]World[/b][/i] [u]Underline[/u]';

$str = preg_replace('~\[b\](.*)\[/b\]~', '<b>$1</b>', $str);
$str = preg_replace('~\[i\](.*)\[/i\]~', '<i>$1</i>', $str);
$str = preg_replace('~\[u\](.*)\[/u\]~', '<u>$1</u>', $str);

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.