doddsey_65 Posted September 5, 2010 Share Posted September 5, 2010 ok bare with me if this sounds stupid. How do i get it so that bbcode can be added within a textarea tag? im assuming it is a lot of str_replace. is there a tutorial on this somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/212595-bbcode/ Share on other sites More sharing options...
wildteen88 Posted September 5, 2010 Share Posted September 5, 2010 Do you mean add bbcode tags (eg ) when the user clicks a button? For this you'll want to use javascript Or to parse bold to bold? For parsing bbcode you'd use regex $str = 'This is some [b]text[/b], bold and [b][u]underlined[/u][/b] [i]italics[/i], [b]bold[/b], [u]underline[/u]'; $str = preg_replace('~\[b\](.*?)\[/b\]~', '<b>\\1</b>', $str); $str = preg_replace('~\[i\](.*?)\[/i\]~', '<u>\\1</u>', $str); $str = preg_replace('~\[u\](.*?)\[/u\]~', '<u>\\1</u>', $str); echo nl2br($str); Quote Link to comment https://forums.phpfreaks.com/topic/212595-bbcode/#findComment-1107503 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.