知识大全 使用PHP获取汉字的拼音
Posted 拼音
篇首语:行是知之始,知是行之成。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 使用PHP获取汉字的拼音相关的知识,希望对你有一定的参考价值。
使用PHP获取汉字的拼音 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
复制代码 代码如下: <?php class GetPingYing private $pylist = array( a => ai => an => ang => ao => ba => bai => ban => bang => bao => bei => ben => beng => bi => bian => biao => bie => bin => bing => bo => bu => ca => cai => can => cang => cao => ce => ceng => cha => chai => chan => chang => chao => che => chen => cheng => chi => chong => chou => chu => chuai => chuan => chuang => chui => chun => chuo => ci => cong => cou => cu => cuan => cui => cun => cuo => da => dai => dan => dang => dao => de => deng => di => dian => diao => die => ding => diu => dong => dou => du => duan => dui => dun => duo => e => en => er => fa => fan => fang => fei => fen => feng => fo => fou => fu => ga => gai => gan => gang => gao => ge => gei => gen => geng => gong => gou => gu => gua => guai => guan => guang => gui => gun => guo => ha => hai => han => hang => hao => he => hei => hen => heng => hong => hou => hu => hua => huai => huan => huang => hui => hun => huo => ji => jia => jian => jiang => jiao => jie => jin => jing => jiong => jiu => ju => juan => jue => jun => ka => kai => kan => kang => kao => ke => ken => keng => kong => kou => ku => kua => kuai => kuan => kuang => kui => kun => kuo => la => lai => lan => lang => lao => le => lei => leng => li => lia => lian => liang => liao => lie => lin => ling => liu => long => lou => lu => lv => luan => lue => lun => luo => ma => mai => man => mang => mao => me => mei => men => meng => mi => mian => miao => mie => min => ming => miu => mo => mou => mu => na => nai => nan => nang => nao => ne => nei => nen => neng => ni => nian => niang => niao => nie => nin => ning => niu => nong => nu => nv => nuan => nue => nuo => o => ou => pa => pai => pan => pang => pao => pei => pen => peng => pi => pian => piao => pie => pin => ping => po => pu => qi => qia => qian => qiang => qiao => qie => qin => qing => qiong => qiu => qu => quan => que => qun => ran => rang => rao => re => ren => reng => ri => rong => rou => ru => ruan => rui => run => ruo => sa => sai => san => sang => sao => se => sen => seng => sha => shai => shan => shang => shao => she => shen => sheng => shi => shou => shu => shua => shuai => shuan => shuang => shui => shun => shuo => si => song => sou => su => suan => sui => sun => suo => ta => tai => tan => tang => tao => te => teng => ti => tian => tiao => tie => ting => tong => tou => tu => tuan => tui => tun => tuo => wa => wai => wan => wang => wei => wen => weng => wo => wu => xi => xia => xian => xiang => xiao => xie => xin => xing => xiong => xiu => xu => xuan => xue => xun => ya => yan => yang => yao => ye => yi => yin => ying => yo => yong => you => yu => yuan => yue => yun => za => zai => zan => zang => zao => ze => zei => zen => zeng => zha => zhai => zhan => zhang => zhao => zhe => zhen => zheng => zhi => zhong => zhou => zhu => zhua => zhuai => zhuan => zhuang => zhui => zhun => zhuo => zi => zong => zou => zu => zuan => zui => zun => zuo => ); //全部拼音 public function getAllPY($chinese $delimiter = $length = ) $py = $this >zh_to_pys($chinese $delimiter); if($length) $py = substr($py $length); return $py; //拼音首个字母 public function getFirstPY($chinese) $result = ; for ($i= ; $i<strlen($chinese); $i++) $p = ord(substr($chinese $i )); if ($p> ) $q = ord(substr($chinese ++$i )); $p = $p* + $q ; $result = substr($this >zh_to_py($p) ); return $result ; // 中文转拼音 // private function zh_to_py($num $blank = ) if($num> && $num< ) return chr($num); elseif ($num< ||$num> ) return $blank; else foreach ($this >pylist as $py => $code) if($code > $num) break; $result = $py; return $result; private function zh_to_pys($chinese $delimiter = $first= ) $result = array(); for($i= ; $i<strlen($chinese); $i++) $p = ord(substr($chinese $i )); if($p> ) $q = ord(substr($chinese ++$i )); $p = $p* + $q ; $result[] = $this >zh_to_py($p); if ($first) return $result[ ]; return implode($delimiter $result); // 中文转拼音结束 // //中文是双字节 所以需要两个字节连接起来(ASCII码的范围是在 ) $c = 齐秦 ; for($i= ; $i<strlen($c); $i++) echo ord($c[$i]) ;// echo <br> chr( ) chr( ) chr( ) chr( ) <br> ; //测试 $PingYing = new GetPingYing(); echo <br> $PingYing >getFirstPY( 羽泉乐队 歌不错 推荐 ) <br> ;//yqldgbc tj echo $PingYing >getAllPY( 羽泉乐队 歌不错 推荐 ) <br> ; //yuquanleduigebucuo tuijian ?> cha138/Article/program/PHP/201311/21313相关参考
PHP将汉字转换拼音 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! PHP将汉字转换拼音是程序员
——此文章摘自《Delphi开发经验技巧宝典》定价¥ 特价¥购买>>//tracklinktechcn/?m_id=dangdang&
——此文章摘自《Delphi开发经验技巧宝典》定价¥ 特价¥购买>>//tracklinktechcn/?m_id=dangdang&
PHP:汉字转为unicode的通用函数 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!<?/
PHP5中GD库生成图形验证码(有汉字) 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!本文为大家介
本篇文章是对php获取$_POST同名参数数组的实现方法进行了详细的分析介绍需要的朋友参考下 今天写php的时候发现$_POST["arr"]无法获取参数arr的数组记录一下例如有以下表
看拼音写汉字:yi()力()立yi(毅)力(屹)立瓢(泼大雨)(蓬荜)生辉飘移,熠熠生辉zhu(驻)军(贮)藏(伫)立YIRANG看拼音,写汉字已让揖让看拼音写汉字yi四声ran二声依然,拼音:yīr
K是什么汉字拼音开头 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!K是什么汉字拼音开头k拼音开头汉
PHP获取文件权限函数介绍 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!以下是对PHP中的获取文件
PHP外部获取函数参数个数 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! functionWar