女士们先生们,早上好。
今天给大家带来的是文字处理类库:汉语拼音PHP类库!
汉字是拼音类(拼写和首字母),这是以前在网上收集的汉语拼音类,这个比较好用。现在和大家分享!
因为代码比较长,需要文件版的人可以私下和我谈谈!
好吧,废话不要多说源代码!
?嗯?PHP
/* *
* Created by PhpStorm .
* User: jifei
* Date: 15/6/25
* Time:下午2:26
*/
Class Pinyin
{
//中文字符串
Private static $ string=
//拼音
Private static $ pinyin=
private static $ encoding=' UTF-8 '
//短拼音
Private static $ short _ pinyin=
//单汉字拼音词典
Private static $dic=array(
“腌菜”=“风筝”,
啊'='a '
强制'='po '
'痛苦'='ai '
'孩子'='ai '
' ail '=' ai ail '
哈克'='ai '
Armadillo '='安'
AO '=' AO '
' u '=' ao '
《小戏》=《纽埃》,
“岘港”=“AO”,
AO '=' AO '
'扒手'='ba '
“诗”=“酒吧”,
'弹性'='pa '
' '='ba '
“莫名其妙”=“一半”,
肩膀'='pang '
磅'='bang '
'总计'='pao '
曝光'='pu '
'大败'='pao '
“瀑布”=“pu”,
“之间”=“雨”,
10-。='pi '
' '='bei '
'味道'='bei '
' polo '=' Bei '
Luang '=' Bei '
“雨”=“雨”,
'是的'='本'
' '='beng '
‘船夫’=‘雨’,
“秘密”=“美”,
提供'='pi '
“分泌”=“美”,
'炮台'='bi '
“啊”=“雨”,
`
;笾' => 'bian',
'扁' => 'bian',
'碥' => 'bian',
'窆' => 'bian',
'便' => 'bian',
'弁' => 'bian',
'缏' => 'bian',
'骠' => 'biao',
'杓' => 'shao',
'飚' => 'biao',
'飑' => 'biao',
'瘭' => 'biao',
'髟' => 'biao',
'玢' => 'bin',
'豳' => 'bin',
'镔' => 'bin',
'膑' => 'bin',
'屏' => 'ping',
'泊' => 'bo',
'逋' => 'bu',
'晡' => 'bu',
'钸' => 'bu',
'醭' => 'bu',
'埔' => 'pu',
'瓿' => 'bu',
'礤' => 'ca',
'骖' => 'can',
'藏' => 'cang',
'艚' => 'cao',
'侧' => 'ce',
'喳' => 'zha',
'刹' => 'sha',
'鲳' => 'chang',
'长' => 'chang',
'苌' => 'chang',
'氅' => 'chang',
'鬯' => 'chang',
'焯' => 'chao',
'朝' => 'chao',
'车' => 'che',
'琛' => 'chen',
'谶' => 'chen',
'榇' => 'chen',
'蛏' => 'cheng',
'埕' => 'cheng',
'枨' => 'cheng',
'塍' => 'cheng',
'裎' => 'cheng',
'螭' => 'chi',
'眵' => 'chi',
'墀' => 'chi',
'篪' => 'chi',
'坻' => 'di',
'瘛' => 'chi',
'种' => 'zhong',
'重' => 'zhong',
'仇' => 'chou',
'帱' => 'chou',
'俦' => 'chou',
'雠' => 'chou',
'臭' => 'chou',
'楮' => 'chu',
'畜' => 'chu',
'嘬' => 'zuo',
'膪' => 'chuai',
'巛' => 'chuan',
'椎' => 'zhui',
'呲' => 'ci',
'兹' => 'zi',
'伺' => 'si',
'璁' => 'cong',
'楱' => 'cou',
'攒' => 'zan',
'爨' => 'cuan',
'隹' => 'zhui',
'榱' => 'cui',
'撮' => 'cuo',
'鹾' => 'cuo',
'嗒' => 'da',
'哒' => 'da',
'沓' => 'ta',
'骀' => 'tai',
'绐' => 'dai',
'埭' => 'dai',
'甙' => 'dai',
'弹' => 'dan',
'澹' => 'dan',
'叨' => 'dao',
'纛' => 'dao',
'簦' => 'deng',
'提' => 'ti',
'翟' => 'zhai',
'绨' => 'ti',
'丶' => 'dian',
'佃' => 'dian',
'簟' => 'dian',
'癜' => 'dian',
'调' => 'tiao',
'铞' => 'diao',
'佚' => 'yi',
'堞' => 'die',
'瓞' => 'die',
'揲' => 'die',
'垤' => 'die',
'疔' => 'ding',
'岽' => 'dong',
'硐' => 'dong',
'缍' => 'duo',
'锷' => 'e',
'鹗' => 'e',
'阏' => 'e',
'诶' => 'ea',
'鲕' => 'er',
'珥' => 'er',
'佴' => 'er',
'番' => 'fan',
'彷' => 'pang',
'霏' => 'fei',
'蜚' => 'fei',
'鲱' => 'fei',
'芾' => 'fei',
'瀵' => 'fen',
'鲼' => 'fen',
'否' => 'fou',
'趺' => 'fu',
'桴' => 'fu',
'莩' => 'fu',
'菔' => 'fu',
'幞' => 'fu',
'郛' => 'fu',
'绂' => 'fu',
'绋' => 'fu',
'祓' => 'fu',
'砩' => 'fu',
'黻' => 'fu',
private static function mbStringToArray($string)
{
$stop = mb_strlen($string, 'utf-8');
$result = array();
for ($idx = 0; $idx < $stop; $idx++) {
$result[] = mb_substr($string, $idx, 1, 'utf-8');
}
return $result;
}
/**
* 汉字转拼音
* @param $string
* @param $encoding
*/
private static function chineseToPinyin($string, $encoding)
{
$words = self::mbStringToArray(mb_convert_encoding($string, 'utf-8', $encoding));
self::$string = $string;
self::$encoding = $encoding;
self::$pinyin = '';
self::$short_pinyin = '';
foreach ($words as $v) {
if (isset(self::$dic[$v])) {
$tmp = self::$dic[$v];
} else {
$tmp = $v;
}
self::$pinyin .= $tmp;
self::$short_pinyin .= mb_substr($tmp, 0, 1, $encoding);
}
}
/**
* 获取拼音
* @param $string
* @param string $encoding
* @return string
*/
public static function getPinyin($string, $encoding = 'utf-8')
{
if ($string != self::$string || $encoding != self::$encoding) {
self::chineseToPinyin($string, $encoding);
}
return self::$pinyin;
}
/**
* 获取拼音缩写
* @param $string
* @param string $encoding
* @return string
*/
public static function getShortPinyin($string, $encoding = 'utf-8')
{
if ($string != self::$string || $encoding != self::$encoding) {
self::chineseToPinyin($string, $encoding);
}
return self::$short_pinyin;
}
}
1.文章《【岙怎么读拼音】阿里云官网,域名实名认证时中文自动拼音PHP类库。》援引自互联网,为网友投稿收集整理,仅供学习和研究使用,内容仅代表作者本人观点,与本网站无关,侵删请点击页脚联系方式。
2.文章《【岙怎么读拼音】阿里云官网,域名实名认证时中文自动拼音PHP类库。》仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证。
相关推荐
- . 现代买票为什么带上携程保险
- . 潮阳怎么去广州南站
- . 湖南马拉河怎么样
- . 烧纸为什么到三岔路口
- . 百色为什么这么热
- . 神州租车怎么样
- . 芜湖方特哪个适合儿童
- . 护肤品保养液是什么类目
- . 早晚的护肤保养有哪些项目
- . 女孩护肤品怎么保养的最好