Home  >  Article  >  Backend Development  >  php 判断字符串

php 判断字符串

WBOY
WBOYOriginal
2016-06-23 14:29:15963browse

php 判断字符串

                  <p class="sycode">                 <?     php     function      checkVS(     $str     ){      //     返回结果为1只有数字,2只有字符,3两者都有                $a     =     0     ;      $b     =     0     ;      for     (     $i     =     0     ;      $i     <     strlen     (     $str     );     $i     ++     ) {       $v     =     ord     (     substr     (     $str     ,     $i     ,     1     ));      if     (     $v     >=     48      and      $v     <=     57     ) {       $a     =     1     ; }       else      {       $b     =     2     ; }  }      return           $a     +     $b     ; }     echo      checkVS(     "     sff     "     )     ?>                  </p>

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
Previous article:PHP的开源项目汇总Next article:php获取OS信息