替换 PHP 字符串中的 HTML 编码符号 (™)
我正在尝试从显示为页面标题的 PHP 字符串中删除编码的 TM 符号。该角色在标题中显示为 ™
,这显然很难看。不幸的是,内置编码函数似乎都无法处理大量编码字符的翻译,TM 也不是其中之一。我想做的是将“™”替换为“(tm)”。
在深入研究子字符串之前,我想看看是否有人知道更聪明的方法来做到这一点。我不知道符号在字符串中出现的位置(它根据页面标题而变化)。
任何想法非常感谢!
I'm trying to remove an encoded TM sign from a PHP string which is displayed as a a page title. The character displays as ™
in the title, which is obviously ugly. Unfortunately none of the inbuilt encoding functions seem to deal with translation of very many encoded characters, and TM isn't one of them. What I want to do is replace '™' with '(tm)'.
Before I dig into substrings I wanted to see if anyone knew of a cleverer way to do this. I don't know the position the symbol appears in the string (it varies depending on the page title).
Any thoughts much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个怎么样:
实际上我不知道这是最好的方法,但至少它有效。
What about this:
Actually I don´t know is it the best way to do this, but at least it works.
据我了解,您希望将 PHP 字符串中的 '
™
' 替换为 '(tm)' 。您只需使用str_replace()
函数即可。它看起来像这样
As I understand it you want to replace the '
™
' with '(tm)' in a string in PHP. You can just use thestr_replace()
function for that.It would look something like this