汉字转换拼音的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(
原生的只有转换 是否返回首字母功能。
扩展后支持
1. 返回格式 [all:全拼音|first:首字母|one:仅第一字符首字母]
2. 无法识别的字符替换用的占位符 (原版写死的是 _ )
3. 允许的非中文字符 正则控制 (原版写死0-9a-zA-Z, 空格都不支持)
用的是他 pinyin.php ~ 206KB 那个UTF8字库,经过压缩扩展后就剩 106K 了。
当然性能也直逼他的,1万次压力测试,他的2.4s,扩展后2.8s,仅仅损耗0.4s,所以可以忽略不计。
免责声明
本站所有资源均由网友贡献或各大下载网站转载。请自行检查软件的完整性!本站所有资源仅供学习参考。请不要将它们用于商业目的。否则,一切后果由您负责!如有侵权,请联系我们删除。联系方式:admin@php.cn
相关文章

20Aug2020
php汉字编码转换的方法:1、使用“string iconv()”方法进行转换;2、通过“mb_convert_encoding”方法进行转换;3、使用“mb_detect_encoding”方法进行转换。

27Oct2024
PHP 中的数组到字符串转换当尝试选择数据库值并使用 PHP 的 SELECT 语句显示它时,您可能会遇到一个常见错误...

21Nov2024
解决 UnsatisfiedLinkError: Can't Find Dependent Libraries in JNI Projects当开发 Java Native Interface (JNI) 项目时,您可能...


Hot Tools

热门文章
丢失记录:Bloom&Rage -Corey和Dylan的锁组合
19Feb2025手游攻略
Hello Kitty 岛冒险:巧克力猫角色指南
24Jan2025手游攻略
如何修复KB5050081无法在Windows 10中安装?
31Jan2025故障排查
Hello Kitty Island冒险:重新启动机器人任务演练
16Feb2025手游攻略
王朝勇士:起源 - Xinye练习之战
26Jan2025手游攻略