Home  >  Article  >  Backend Development  >  A function that can convert Chinese characters into pinyin_PHP tutorial

A function that can convert Chinese characters into pinyin_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 10:59:461061browse

​ Many problems are caused by Chinese language problems
For example, it is best not to use Chinese characters for file names
The current solution is generally to generate an ID and use this ID as the file name
If the URL contains Chinese characters on the web page, there will often be errors
The current solution is generally to use urlencode encoding
Now that I’ve used this transformation, it’s much better
Principle: Using multi-dimensional arrays
1. Add index
2. Traverse the array
$d=array(
array("a",-20319),
array("ai",-20317),
array("an",-20304),
array("ang",-20295),
array("ao",-20292),
array("ba",-20283),
array("bai",-20265),
array("ban",-20257),
array("bang",-20242),
array("bao",-20230),
array("bei",-20051),
array("ben",-20036),
array("beng",-20032),
array("bi",-20026),
array("bian",-20002),
array("biao",-19990),
array("bie",-19986),
array("bin",-19982),
array("bing",-19976),
array("bo",-19805),
array("bu",-19784),
array("ca",-19775),
array("cai",-19774),
array("can",-19763),
array("cang",-19756),
array("cao",-19751),
array("ce",-19746),
array("ceng",-19741),
array("cha",-19739),
array("chai",-19728),
array("chan",-19725),
array("chang",-19715),
array("chao",-19540),
array("che",-19531),
array("chen",-19525),
array("cheng",-19515),
array("chi",-19500),
array("chong",-19484),
array("chou",-19479),
array("chu",-19467),
array("chuai",-19289),
array("chuan",-19288),
array("chuang",-19281),
array("chui",-19275),
array("chun",-19270),

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445588.htmlTechArticleMany problems are caused by Chinese problems. For example, it is best not to use Chinese for file names. The current solution is generally to generate An ID, use this ID as the file name. If the URL contains Chinese characters on the web page, it will often appear...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn