php判断中文,英文, 数字

exeg 

Warning  This function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0.

function checkStr($str){
  $output='';
  $arr = array();
  preg_match('/['.chr(0xa1).'-'.chr(0xff).']/', $str, $a, PREG_OFFSET_CAPTURE);
  
  preg_match('/[0-9]/', $str, $b, PREG_OFFSET_CAPTURE);
  
  preg_match('/[a-zA-Z]/', $str, $c, PREG_OFFSET_CAPTURE);
  
  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;
}

 

posted @ 2016-08-11 14:46  知子  阅读(1007)  评论(0编辑  收藏  举报