c_pattle Posted December 5, 2012 Share Posted December 5, 2012 I have a php script that needs to replace trademark symbols in a string. At the moment it works by doing str_replace(™, '', $string); This works when I have tested it on Windows but is this a bad way of doing it? I'm guessing it is. Does anyone know a better way. I know I could convert the string to html entities and then replace the html code but I don't want to do this as there are other things in the string I don't want to convert to html entities. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/271628-replacing-trademark-character/ Share on other sites More sharing options...
Christian F. Posted December 5, 2012 Share Posted December 5, 2012 That works just fine, as long as you ensure that the search string and the haystack are encoded with the same charset. Which they have to be, seeing as it works. PS: Just remember to quote the TM symbol, as it's not a constant. Quote Link to comment https://forums.phpfreaks.com/topic/271628-replacing-trademark-character/#findComment-1397671 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.