Home >Backend Development >PHP Tutorial >GBK to pinyin pinyin, please note that it is not the GB2312 to pinyin that is everywhere on the Internet
After searching on the Internet, "PHP to Pinyin" is everywhere, but the code only supports GB2312.
Even the words "骞", "霜", and "Hui" cannot be supported. For converting Chinese names to Pinyin, that code is far from enough. A correct GBK to Pinyin code is now announced. Many thanks to the original author: Ma Minglian (!hightman) Home page: http://php.twomice.net The original DEMO only supports one-word query. I modified it to support a string, both Chinese and English. The original text is returned in English, and the Chinese characters are converted into pinyin with tones. Multi-phonetic characters are not supported for the time being. For example, "Zeng" will be converted to ceng2, but there is no zeng1. (There is a yii-chinese PHP project on the Internet, but unfortunately the pinyin conversion is also GB2312) How to use: $str = 'Chinese characters abc123-=+'; $py = pinyin::instance(); //Single instance, if you like, $py = new pinyin(); also works. echo $py->get($str); Please download the entire code at the end of the page. ![]()
|