gpt4 book ai didi

php 中文字符串首字母的获取函数分享

转载 作者:qq735679552 更新时间:2022-09-29 22:32:09 25 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章php 中文字符串首字母的获取函数分享由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

复制代码 代码如下

function chineseFirst($str) {     $str= iconv("UTF-8","gb2312", $str);    //如果程序是gbk的,此行就要注释掉     //判断字符串是否全都是中文     if (preg_match("/^[\x7f-\xff]/", $str))     {         $fchar=ord($str{0});           if($fchar>=ord("A") and $fchar<=ord("z") )return strtoupper($str{0});         $a = $str;         $val=ord($a{0})*256+ord($a{1})-65536;         if($val>=-20319 and $val<=-20284)return "A";           if($val>=-20283 and $val<=-19776)return "B";           if($val>=-19775 and $val<=-19219)return "C";           if($val>=-19218 and $val<=-18711)return "D";           if($val>=-18710 and $val<=-18527)return "E";           if($val>=-18526 and $val<=-18240)return "F";           if($val>=-18239 and $val<=-17923)return "G";           if($val>=-17922 and $val<=-17418)return "H";         if($val>=-17417 and $val<=-16475)return "J";                         if($val>=-16474 and $val<=-16213)return "K";                         if($val>=-16212 and $val<=-15641)return "L";                         if($val>=-15640 and $val<=-15166)return "M";                         if($val>=-15165 and $val<=-14923)return "N";                         if($val>=-14922 and $val<=-14915)return "O";                         if($val>=-14914 and $val<=-14631)return "P";                         if($val>=-14630 and $val<=-14150)return "Q";                         if($val>=-14149 and $val<=-14091)return "R";                         if($val>=-14090 and $val<=-13319)return "S";                         if($val>=-13318 and $val<=-12839)return "T";                         if($val>=-12838 and $val<=-12557)return "W";                         if($val>=-12556 and $val<=-11848)return "X";                         if($val>=-11847 and $val<=-11056)return "Y";                         if($val>=-11055 and $val<=-10247)return "Z";     } else     {         return false;     } } 。

最后此篇关于php 中文字符串首字母的获取函数分享的文章就讲到这里了,如果你想了解更多关于php 中文字符串首字母的获取函数分享的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com