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? 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); Link to comment https://forums.phpfreaks.com/topic/212595-bbcode/#findComment-1107503 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.