hello, has anybody done this before? I want to convert all the html tags into bbcode like: <UL></UL> PHP: to [ list ][ /list ] (just take the space off before and after list. i could not write them together) is there any ready script to do this? thanks
Here you go! <? $your_text = "This is some <b>cool</b> <u>HTML-Tags</u>.. Make us BB-Tags"; $htmltags = array( '/\<b\>(.*?)\<\/b\>/is', '/\<i\>(.*?)\<\/i\>/is', '/\<u\>(.*?)\<\/u\>/is', '/\<ul\>(.*?)\<\/ul\>/is' ); $bbtags = array( '[b]$1[/b]', '[i]$1[/i]', '[u]$1[/u]', '[list]$1[/list]' ); $your_text = preg_replace ($htmltags, $bbtags, $your_text); echo $your_text; ?> PHP: