开发者

Convert Special Characters (other language) to English in PHP

开发者 https://www.devze.com 2022-12-22 02:39 出处:网络
Is there a function that coverts sp开发者_如何学Pythonecial characters to their english equivalents. For Eg. Convert é to e. Etc...The function you are after is iconv() - from the user notes, this se

Is there a function that coverts sp开发者_如何学Pythonecial characters to their english equivalents. For Eg. Convert é to e. Etc...


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:

setlocale(LC_CTYPE, 'nl_BE.utf8');
$string = iconv('UTF-8', 'ASCII//TRANSLIT', $string);

I've tested it a lot of accentuated characters


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号