search
Homephp教程PHP源码过滤字符串中的中文和数字

过滤字符串中的中文和数字

function getChinese($string,$encode="GBK") {
       switch($encode){
            case "GBK" :$codelength=2;break;
       case "GB2312" :$codelength=3;break;
       case "UTF-8" :$codelength=3;break;
           case "UTF-16" :$codelength=4;break;
 
       }
       $tmpstr = '';
       $arr = array(1,2,3,4,5,6,7,8,9,0);
       $strlen = strlen($string);
       for($i=0; $i0xA0 ){
            $tmpstr.= substr($string, $i, $codelength);
            $i = $i+$codelength-1;
            }
 
}
    return $tmpstr;
}

                   

以上就是过滤字符串中的中文和数字的内容,更多相关内容请关注PHP中文网(www.php.cn)!

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

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools