php 如何判断字符串是13或者14开头的

来源:百度知道 编辑:UC知道 时间:2024/09/25 02:28:27
php 如何判断字符串是13或者14开头的

preg_match("/^1(3)?(4)?/", $str)

if(preg_match('/^(13|14).*$/',$str)){
echo '<hr>yes';

}

$first = substr($str,0,1);
$second = substr($str,1,1);
if($first==1&&($second==3||$second==4)){
echo "right";
}

if(preg_match("/1[3,4]/", $str)){
echo "true";
}
else{
echo "false";
}

上面都正确