teomanersan Posted June 22, 2006 Share Posted June 22, 2006 hi guys..i am using two bbcode tags for linking inside my site which are [bkz] [/bkz] and [bkz] [*bkz]for this, i'm using this code..[code]$comment = preg_replace("#\[bkz](.*?)\[/bkz\]#ise", "'<a title=\"(bkz.\\1)\" href=\"ajaxcomsayfa.php?ara='.urlencode('\\1').'\">\\1</a>'",$comment);$comment = preg_replace("#\[bkz](.*?)\[\*bkz\]#ise", "'<a title=\"(bkz.\\1)\" href=\"ajaxcomsayfa.php?ara='.urlencode('\\1').'\" >*</a>'",$comment);[/code]works fine.. but now i want to convert bbcode to html.. so i used preg_replace again..[code]$comment = preg_replace("#(<a title=(.+?) href=(.+?) >(.+?)</a>)#is","[bkz]\\1[/bkz]",$comment);$comment = preg_replace("#(<a title=(.+?) href=(.+?) >\*</a>)#is","[bkz]\\1[/*bkz]",$comment);[/code]now the problem starts ... it gives the output like this IF i use $comment = striptags($comment) and both tags were used.. [bkz][bkz]test*[*bkz][/bkz]if only one tag is used, nothing shows up :((else it gives tags plus the html codes and drives me NUTS !!!!please if anyone know how to get rid of this problem, let me know !!!basicly what i want is:<a title="(bkz.test)" href="ajaxcomsayfa.php?ara=test">test</a> TO -> [bkz]test[/bkz]<a title="(bkz.test)" href="ajaxcomsayfa.php?ara=test">*</a> TO -> [bkz]test[*bkz]thanx for your time and any help is HIGHLY appericiated..good coding Link to comment https://forums.phpfreaks.com/topic/12610-please-help-about-bbcode/ Share on other sites More sharing options...
hackerkts Posted June 22, 2006 Share Posted June 22, 2006 Hmm.. Are you trying to make bbcode ?Try this function I'm using:[code]<?phpfunction bbcode($text){$pattern[] = '//';$replace[] = '';$pattern[] = '/\n/';$replace[] = '<br>';$pattern[] = '/\[b\](.*?)\[\/b\]/';$replace[] = '<span style="font-weight:bold">$1</span>';$pattern[] = '/\[i\](.*?)\[\/i\]/';$replace[] = '<span style="font-style:italic">$1</span>';$pattern[] = '/\[u\](.*?)\[\/u\]/';$replace[] = '<span style="text-decoration:underline">$1</span>';$pattern[] = '/\[color=(.*?)\](.*?)\[\/color\]/';$replace[] = '<span style="color: $1">$2</span>';$pattern[] = '/\[url=(.*?)\](.*?)\[\/url\]/';$replace[] = '<a href="$1">$2</a>';$pattern[] = '/\[url\](.*?)\[\/url\]/';$replace[] = '<a href="$1">$1</a>';$pattern[] = '/\[img\](.*?)\[\/img\]/';$replace[] = '<img src="$1">';$pattern[] = '/\[b\](.*?)\[\/b\]/';$replace[] = '<b>$1</b>';$pattern[] = '/\[bkz\](.*?)\[\/bkz\]/';$replace[] = '<a title="(bkz.$1)" href="ajaxcomsayfa.php?ara=test">$1</a>';$pattern[] = '/\[bkz\](.*?)\[\*bkz\]/';$replace[] = '<a title="(bkz.$1)" href="ajaxcomsayfa.php?ara=test">$1</a>';$text = preg_replace($pattern, $replace, $text);return $text;}?>[/code]P.S : I have added I have added what you want at the last 2 bbcode, save this file as functions.php or anything.Usage:[code]<?phpinclude('functions');$text = "[bkz]test[/bkz]";echo bbcode($text);?>[/code]Enjoy :) Link to comment https://forums.phpfreaks.com/topic/12610-please-help-about-bbcode/#findComment-48406 Share on other sites More sharing options...
teomanersan Posted June 22, 2006 Author Share Posted June 22, 2006 no i`m not trying to make bbcode.. i`m trying to convert bbcode into html equivalent..thx :) Link to comment https://forums.phpfreaks.com/topic/12610-please-help-about-bbcode/#findComment-48414 Share on other sites More sharing options...
teomanersan Posted June 24, 2006 Author Share Posted June 24, 2006 c`mon guys ? is it impossible ? Link to comment https://forums.phpfreaks.com/topic/12610-please-help-about-bbcode/#findComment-49084 Share on other sites More sharing options...
hackerkts Posted June 25, 2006 Share Posted June 25, 2006 My reply doesn't helped ?I thought you want to have bbcode that convert to html when you typed[bkz]blah...[/bkz]and[bkz]blah...[*bkz] Link to comment https://forums.phpfreaks.com/topic/12610-please-help-about-bbcode/#findComment-49263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.