FXMAR 发表于 2017-3-22 10:23:40

php中英文判断

static function ischinese($s){
$allen = preg_match("/^[^\x80-\xff]+$/", $s);
$allcn = preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/",$s);
if($allen){
return 'allen';
}else{
if($allcn){
return 'allcn';
}else{
return 'encn';
}
}
}
页: [1]
查看完整版本: php中英文判断