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 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. Link to comment https://forums.phpfreaks.com/topic/271628-replacing-trademark-character/#findComment-1397671 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.