【文件属性】:
文件名称:PHP汉字拼音转换
文件大小:7KB
文件格式:ZIP
更新时间:2016-09-11 07:21:21
PHP 汉字拼音转换
Pinyin.class.php类文件可以将大多数汉字转换成汉语拼音,当然也有个别生僻字不能转换,如果你想转换所有的汉字拼音的话,可能需要再配合一个汉字字库来实现,使用该类文件就基本能满足你的项目需求了。用法:
require_once("Pinyin.class.php");
$pinyin = new Pinyin();
$str = '好好学习天天向上';
echo $pinyin->strtopin($str);
执行后输出:hao hao xue xi tian tian xiang shang。
如果只是想输出汉字首字母则使用:
echo $pinyin->strtopin($str,1);
执行后输出:hhxxttxs。
【文件预览】:
Pinyin.class.php
Lunar.class.php