php 判断字符串

<?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")
?>

相关文章:

  • 2021-05-25
  • 2021-06-20
  • 2022-12-23
  • 2022-02-22
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-02
  • 2021-07-25
  • 2022-12-23
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案