Jump to content

Replacing Trademark Character


c_pattle

Recommended Posts

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

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. ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.