php判断汉字 字母和数字
PHP判断数字,汉字和英文
悬赏分:0 | 解决时间:2010-5-14 16:33 | 提问者:虾米熟了分别判断数字汉字和英文。 给出一字符串,判断出是纯数字、纯汉字、纯英文还是谁和谁的混合字符串。 要简洁。 采纳给20分。最佳答案
<?
function checkStr($str){
    $output='';
    $a=ereg('['.chr(0xa1).'-'.chr(0xff).']', $str);
    $b=ereg('[0-9]', $str);
    $c=ereg('[a-zA-Z]', $str);
    if($a && $b && $c){ $output='汉字数字英文的混合字符串';}
    elseif($a && $b && !$c){ $output='汉字数字的混合字符串';}
    elseif($a && !$b && $c){ $output='汉字英文的混合字符串';}
    elseif(!$a && $b && $c){ $output='数字英文的混合字符串';}
    elseif($a && !$b && !$c){ $output='纯汉字';}
    elseif(!$a && $b && !$c){ $output='纯数字';}
    elseif(!$a && !$b && $c){ $output='纯英文';}
    return $output;
}
echo checkStr('5爱u');
?>顶(0)
 踩(0)
 上一篇:php mb_substr  
          下一篇:php 限制IP访问  
        - 最新评论
