UnknownPlayer Posted September 30, 2010 Share Posted September 30, 2010 I have problem, when i put these characters: čšđć in my var to echo it works, but when i use these characters in bbcode($Input) function it does not show that characters, it shows me Ä� or something like that. Or when i put more spaces in var(var goes through bbcode($input) function) it show me Ä this character. How can i fix this problem? This is bbcode function: function bbcode($input){ $input = strip_tags($input); $input = htmlentities($input); $search = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[code\](.*?)\[\/code\]/is', '/\[quote\](.*?)\[\/quote\]/is', '/\[img\](.*?)\[\/img\]/is', '/\[url=http://(.*?)\](.*?)\[\/url\]/is', '/\[color=(.*?)\](.*?)\[\/color\]/is', '/\[yt\]http:\/\/(?:www\.)?youtube\.com\/watch\?v=(.*?)\[\/yt\]/is', ); $replace = array( '<b>$1</b>', '<i>$1</i>', '<u>$1</u>', '<code>$1</code>', '<blockquote>$1</blockquote>', '<img src="$1" style="border:0">', '<a href="$1">$2</a>', '<font style="color:$1">$2</font>', '<object width="580" height="360"> <param name="movie" value="http://www.youtube.com/v/$1?fs=1&hl=sr_RS&border=1" /> <param name="allowFullScreen" value="true" /> <param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" width="580" height="360" src="http://www.youtube.com/v/$1?fs=1&hl=sr_RS&border=1" allowscriptaccess="always" allowfullscreen="true"></embed> </object>', ); return nl2br(preg_replace($search,$replace,$input)); } I think that problem is becouse of tihis: $input = strip_tags($input); $input = htmlentities($input); Help please. Quote Link to comment Share on other sites More sharing options...
Chris92 Posted September 30, 2010 Share Posted September 30, 2010 If you're going to use htmlenitities I don't think there would be much need for strip_tags. Quote Link to comment Share on other sites More sharing options...
UnknownPlayer Posted September 30, 2010 Author Share Posted September 30, 2010 And what is suggestion for this problem, how to fix it? Quote Link to comment Share on other sites More sharing options...
UnknownPlayer Posted September 30, 2010 Author Share Posted September 30, 2010 It works, when i remove $input = htmlentities($input);, will that be a problem if that code is removed? Quote Link to comment Share on other sites More sharing options...
jcbones Posted September 30, 2010 Share Posted September 30, 2010 If you use strip_tags(), then yes. Since there will be no entities to process. Quote Link to comment Share on other sites More sharing options...
UnknownPlayer Posted September 30, 2010 Author Share Posted September 30, 2010 I use function like this now: function bbcode($input){ $input = strip_tags($input); $search = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[code\](.*?)\[\/code\]/is', '/\[quote\](.*?)\[\/quote\]/is', '/\[img\](.*?)\[\/img\]/is', '/\[url=http://(.*?)\](.*?)\[\/url\]/is', '/\[color=(.*?)\](.*?)\[\/color\]/is', '/\[yt\]http:\/\/(?:www\.)?youtube\.com\/watch\?v=(.*?)\[\/yt\]/is', ); $replace = array( '<b>$1</b>', '<i>$1</i>', '<u>$1</u>', '<code>$1</code>', '<blockquote>$1</blockquote>', '<img src="$1" style="border:0">', '<a href="$1">$2</a>', '<font style="color:$1">$2</font>', '<object width="580" height="360"> <param name="movie" value="http://www.youtube.com/v/$1?fs=1&hl=sr_RS&border=1" /> <param name="allowFullScreen" value="true" /> <param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" width="580" height="360" src="http://www.youtube.com/v/$1?fs=1&hl=sr_RS&border=1" allowscriptaccess="always" allowfullscreen="true"></embed> </object>', ); return nl2br(preg_replace($search,$replace,$input)); } That is wrong, or no ? How can i use this function on right way ? :/ Quote Link to comment 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.