在 PHP 中将特殊字符(其他语言)转换为英语
是否有一个函数可以将特殊字符转换为其英文等效字符。对于例如。将 é 转换为 e。 ETC...
Is there a function that coverts special characters to their english equivalents. For Eg. Convert é to e. Etc...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您想要的函数是 iconv() - 从用户注释来看,这似乎成为你想做的事:字符音译
The function you are after is iconv() - from the user notes, this seems to be what you want to do: characters transliteration
你应该使用这个,它会起作用:
我已经测试了很多重音字符
You should use this one and it will works:
I've tested it a lot of accentuated characters
如果您不喜欢 danp 的解决方案 (iconv),您可以使用带有转换列表的
strtr
。 这个页面有一个示例脚本(第一个Google结果)。If you don't like danp's solution (iconv), you could use
strtr
with a list of conversions. This page has a sample script (first Google result).如果 iconv() 不适合您,您可以创建一个函数来保存要交换的字符数组并传递字符串,然后将 ã 更改为这种方式。
You could make a function holding a array of chars you want exchanged and pass strings through and just change ã to a that way, if iconv() doesn´t work out for you.