Convert special characters to normal characters using PHP, like ã, é, ç to a, e, c [closed]

随声附和 提交于 2019-12-22 10:46:30

问题


I would like to convert special characters to normal characters using PHP.

For example.

ã, á, à, é, ç, ...

to

a, a, a, e, c, ...

It would be great if someone could help me with the issue I'm having.


回答1:


$ts = array("/[À-Å]/","/Æ/","/Ç/","/[È-Ë]/","/[Ì-Ï]/","/Ð/","/Ñ/","/[Ò-ÖØ]/","/×/","/[Ù-Ü]/","/[Ý-ß]/","/[à-å]/","/æ/","/ç/","/[è-ë]/","/[ì-ï]/","/ð/","/ñ/","/[ò-öø]/","/÷/","/[ù-ü]/","/[ý-ÿ]/");
$tn = array("A","AE","C","E","I","D","N","O","X","U","Y","a","ae","c","e","i","d","n","o","x","u","y");
preg_replace($ts,$tn, $p);

Make an array of the special characters and an array of the regular character and use preg_replace() on the string like above.



来源:https://stackoverflow.com/questions/4511194/convert-special-characters-to-normal-characters-using-php-like-%c3%a3-%c3%a9-%c3%a7-to-a-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!