沃梦达 / 编程问答 / php问题 / 正文

使用PHP将特殊字符转换为普通字符,如将ã、é、ç转换为a、e、c

Convert special characters to normal characters using PHP, like #227;, #233;, #231; to a, e, c(使用PHP将特殊字符转换为普通字符,如将#227;、#233;、#231;转换为a、e、c)

本文介绍了使用PHP将特殊字符转换为普通字符,如将ã、é、ç转换为a、e、c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用PHP将特殊字符转换为普通字符。

例如。

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

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

如果有人能帮我解决我遇到的问题,那就太好了。

推荐答案

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

创建一个由特殊字符组成的数组和一个由常规字符组成的数组,并对字符串使用preg_place(),如下所示。

这篇关于使用PHP将特殊字符转换为普通字符,如将ã、é、ç转换为a、e、c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用PHP将特殊字符转换为普通字符,如将ã、é、ç转换为a、e、c

基础教程推荐