UnknownPlayer Posted September 15, 2010 Share Posted September 15, 2010 I use this bbc code. This is bbccode_function.php: <?php function bbcode($input){ $input = strip_tags($input); $input = htmlentities($input); $search = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[img\](.*?)\[\/img\]/is', '/\[url=http://(.*?)\](.*?)\[\/url\]/is', '/\[font color=(.*?) size=(.*?) face=(.*?)\](.*?)\[\/font\]/is', '/\[h1\](.*?)\[\/h1\]/is', '/\[special\](.*?)\[\/hat\]/is' ); $replace = array( '<b>$1</b>', '<i>$1</i>', '<u>$1</u>', '<img src="$1">', '<a href="$1">$2</a>', '<font style="color:$1;font-size:$2;font-face:$3">$4</font>', '<h1>$1</h1>', '<a href="http://google.com" style="font-size:32pt;text-decoration:blink;color:#FF0099">$1</a>' ); return preg_replace($search,$replace,$input); } ?> And this is test page: <?php include "bbcode_function.php"; $var = "[b]text[/b]"; echo bbcode($var); ?> But when i put <br \> code in $var, it does not goes to new row. I use this bbc code in textarea, and i need when i go in new row in textarea to use that bbc code, or somehow to make that work :S How can i do that? Link to comment https://forums.phpfreaks.com/topic/213526-bbc-code-question/ Share on other sites More sharing options...
jcbones Posted September 15, 2010 Share Posted September 15, 2010 You are stripping the tags. try: <?php include "bbcode_function.php"; $var = "[b]text[/b]\n[i]me[/i]"; echo nl2br(bbcode($var)); ?> Link to comment https://forums.phpfreaks.com/topic/213526-bbc-code-question/#findComment-1111492 Share on other sites More sharing options...
UnknownPlayer Posted September 16, 2010 Author Share Posted September 16, 2010 Thanks. Link to comment https://forums.phpfreaks.com/topic/213526-bbc-code-question/#findComment-1111857 Share on other sites More sharing options...
UnknownPlayer Posted September 17, 2010 Author Share Posted September 17, 2010 Anyway is there any php code that put icons for bbc code, i mean on ,,, like on forum, and when i click to make selected text for example ? This thing: Link to comment https://forums.phpfreaks.com/topic/213526-bbc-code-question/#findComment-1111919 Share on other sites More sharing options...
jcbones Posted September 17, 2010 Share Posted September 17, 2010 You use javascript for that. The most popular is TinyMCE Link to comment https://forums.phpfreaks.com/topic/213526-bbc-code-question/#findComment-1112324 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.