codecible / yii2-chinesepinyin
The chinesepinyin integration for the Yii framework
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-10-18 16:19:49 UTC
README
yii2版, 可以获取汉字的拼音
安装方法
1.命令安装
php composer.phar require codecible/yii2-chinesepinyin 或 composer require codecible/yii2-chinesepinyin
代码中使用
$Pinyin = new ChinesePinyin(); $str = '带声调的汉语拼音'; $ret = $Pinyin->TransformWithTone($str); var_dump($ret); echo '<br/>'; $str = '无声调的汉语拼音,凡芃团队'; $ret = $Pinyin->TransformWithoutTone($str); var_dump($ret); echo '<br/>'; $str = '首字母只包括汉字BuHanPinYin'; $ret = $Pinyin->TransformUcwordsOnlyChar($str); var_dump($ret); echo '<br/>'; $str = '首字母和其他字符如B区32号'; $ret = $Pinyin->TransformUcwords($str); var_dump($ret); string(40) "dài shēng diào de hàn yǔ pīn yīn " string(38) "wushengdiaodehanyupinyinfanpengtuandui" string(8) "SZMZBKHZ" string(14) "szmhqtzfrBq32h"