Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.