$a='0123-';
if(preg_match('/\D/',$a,$b)){
echo "范围超过0-9";
}

解决方案 »

  1.   

    全角转半角PHP还不知道,JS是这样的
    /**************************** 
    * 参数说明: 
    *  全角->半角
    * str:要转换的字符串 
    * 返回值类型:字符串 
    **************************** /
    function DBC2SBC(str) { 
     var i; 
     var result=''; 
     for(i=0;i<str.length;i++) { 
      code=str.charCodeAt(i); 
      if(code>=65281&&code<65373)    
        result+=String.fromCharCode(str.charCodeAt(i)-65248); 
      else result+=str.charAt(i);
      } 
     alert(result);
     return result; 

      

  2.   

    $a='0123-';
    if(preg_match('/\D/',$a,$b)){
      echo "范围超过0-9";
    }其中的 $b 是表示的什么?
      

  3.   

    把匹配完的值赋值给$b,$b是个ARRAY