function getFirstChar($string){

if($string{0}>="A" and $string{0}<="z" )return strtoupper($string{0});
    $s=iconv("UTF-8","gb2312", $string);
    $asc=ord($s{0})*256+ord($s{1})-65536;
    
    if($asc>=-20319 and $asc<=-20284)return "A";
    if($asc>=-20283 and $asc<=-19776)return "B";
    if($asc>=-19775 and $asc<=-19219)return "C";
    if($asc>=-19218 and $asc<=-18711)return "D";
    if($asc>=-18710 and $asc<=-18527)return "E";
    if($asc>=-18526 and $asc<=-18240)return "F";
    if($asc>=-18239 and $asc<=-17923)return "G";
    if($asc>=-17922 and $asc<=-17418)return "H";
    if($asc>=-17417 and $asc<=-16475)return "J";
    if($asc>=-16474 and $asc<=-16213)return "K";
    if($asc>=-16212 and $asc<=-15641)return "L";
    if($asc>=-15640 and $asc<=-15166)return "M";
    if($asc>=-15165 and $asc<=-14923)return "N";
    if($asc>=-14922 and $asc<=-14915)return "O";
    if($asc>=-14914 and $asc<=-14631)return "P";
    if($asc>=-14630 and $asc<=-14150)return "Q";
    if($asc>=-14149 and $asc<=-14091)return "R";
    if($asc>=-14090 and $asc<=-13319)return "S";
    if($asc>=-13318 and $asc<=-12839)return "T";
    if($asc>=-12838 and $asc<=-12557)return "W";
    if($asc>=-12556 and $asc<=-11848)return "X";
    if($asc>=-11847 and $asc<=-11056)return "Y";
    if($asc>=-11055 and $asc<=-10247)return "Z";
    return null;
}

php 获取汉字拼音首字母的函数的更多相关文章

  1. C# 获取汉字拼音首字母

    最近悟出来一个道理,在这儿分享给大家:学历代表你的过去,能力代表你的现在,学习代表你的将来. 十年河东十年河西,莫欺少年穷 学无止境,精益求精   本节探讨C#获取汉字拼音首字母的方法: 代码类东西, ...

  2. C# 获取汉字拼音首字母/全拼

    最近悟出来一个道理,在这儿分享给大家:学历代表你的过去,能力代表你的现在,学习代表你的将来. 十年河东十年河西,莫欺少年穷 学无止境,精益求精   本节探讨C#获取汉字拼音首字母的方法: 代码类东西, ...

  3. java获取汉字拼音首字母 --转载

    在项目中要更能根据某些查询条件(比如姓名)的首字母作为条件进行查询,比如查一个叫"李晓明"的人,可以输入'lxm'.写了一个工具类如下: import java.io.Unsupp ...

  4. JAVA获取汉字拼音首字母

    package com.common.util; import java.io.UnsupportedEncodingException; /** * 取得给定汉字串的首字母串,即声母串 * Titl ...

  5. php获取汉字拼音首字母的方法

    现实中我们经常看到这样的说明,排名不分先后,按姓名首字母进行排序.这是中国人大多数使用的排序方法.那么在php程序中该如何操作呢? 下面就分享一下在php程序中获取汉字拼音的首字母的方法,在网上搜到的 ...

  6. C/C++ 获取汉字拼音首字母

    #include <stdint.h> #include <stdio.h> #include <ctype.h> #include <string.h> ...

  7. qt 获取汉字拼音首字母

    #include "mainwindow.h"#include "ui_mainwindow.h"#include <QDebug>#include ...

  8. 获取汉字拼音&首字母

    pinyin4j https://www.cnblogs.com/yjq520/p/7681537.html

  9. PHP获取汉字拼音首字母 截取中文字符串

    http://blog.csdn.net/everything1209/article/details/39005785 substr是按字符分割,而mb_strcut是按字节来分割,但是都不会产生半 ...

随机推荐

  1. Apriori algorithm

    本文是个人对spmf中example1. mining frequent itemsets by  using the apriori algorithm的学习. What is Apriori? A ...

  2. 一次rman恢复的实验

    本文主要针对备份和恢复数据文件,具体rman知识点查阅我的另一篇文章:http://blog.csdn.net/perfect_db/article/details/8765022 首先看看数据文件的 ...

  3. docker文章

    https://training.docker.com/self-paced-training http://special.csdncms.csdn.net/BeDocker/ http://clo ...

  4. Map map=new HashMap(); 为什么是这样

    Map是接口,hashMap是Map的一种实现.接口不能被实例化. Map map=new HashMap(); 就是将map实例化成一个hashMap.这样做的好处是调用者不需要知道map具体的实现 ...

  5. uva 10382 Watering Grass_贪心

    题意:给你个矩形n*m,再给你n个圆的圆心坐标和半径,问最用最少用几个圆把这个矩形覆盖 思路:直接想发现这问题不容易,后来发现可以把圆看做区间(能把矩形面积覆盖),然后这个问题就容易解决了 #incl ...

  6. linux下的时间及时区设置

    一.时间设置及同步 1修改系统时间 #date -s 06/18/14 #date -s 14:20:50 2命令查看.设置硬件时间 #hwclock  --show 或者clock  --show ...

  7. input的样式简介

    <input type="text" autocomplete="off" placeholder="" x-webkit-speec ...

  8. 蜗牛爱课- iOS中定时器NSTimer使用

    调用一次计时器方法: //不重复,只调用一次.timer运行一次就会自动停止运行 self.locationTimer = [NSTimer  target:self selector: @selec ...

  9. Gson解析JsonObject和JsonArray

    Gson中重要的几个核心类: Gson.JsonParser.JsonObject.JsonArray. 下面就是解析的步骤: public void parserJsonArray(String s ...

  10. sed使用详解

    sed :Stream EDitor(流编辑器) sed :模式空间(默认不编辑源文件,仅对模式空间中数据做处理) sed [options] 'AddressCommand' file ... -n ...