search
Homephp教程php手册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        $a = $str;
        $val=ord($a{0})*256+ord($a{1})-65536;
        if($val>=-20319 and $val        if($val>=-20283 and $val        if($val>=-19775 and $val        if($val>=-19218 and $val        if($val>=-18710 and $val        if($val>=-18526 and $val        if($val>=-18239 and $val        if($val>=-17922 and $val        if($val>=-17417 and $val        if($val>=-16474 and $val        if($val>=-16212 and $val        if($val>=-15640 and $val        if($val>=-15165 and $val        if($val>=-14922 and $val        if($val>=-14914 and $val        if($val>=-14630 and $val        if($val>=-14149 and $val        if($val>=-14090 and $val        if($val>=-13318 and $val        if($val>=-12838 and $val        if($val>=-12556 and $val        if($val>=-11847 and $val        if($val>=-11055 and $val    } else
    {
        return false;
    }

}

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor