多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 依赖 参见[PHP汉字转全拼和首字母,支持带声调和保留非字母内容](http://www.thinkphp.cn/code/1482.html) 将文章的附件放入直接放在Library\Org\Util里就可以了。 ## 效果 ![](https://box.kancloud.cn/2015-11-28_565979770ca10.png) ## 实现 参见随书项目 yang_book/examples/startup/PinyinController.class.php ~~~ public function example(){ $Pinyin = new \Org\Util\ChinesePinyin(); echo $Pinyin->TransformWithTone("带声调的汉语拼音"); echo '<br>'; echo $Pinyin->TransformWithoutTone("无声调的汉语拼音"); echo '<br>'; echo $Pinyin->TransformUcwordsOnlyChar("首字母只包括汉字BuHanPinYin"); echo '<br>'; echo $Pinyin->TransformUcwords("首字母和其他字符如B区32号"); } ~~~ ## 应用场景 一些文章发布系统或者商城会要求存某个字段如标题的拼音字符串,这样方便用户生僻字用 拼音去搜索。