//$new_phone_number)为传过来的电话号码
if (strlen($new_phone_number) > 4)
{//不是分机号码,这里分机号码为4位
if ($prefix_dial != '')
{//出局前缀不为空
$lenth=strlen($new_phone_number);
$phone_number_1 = substr($new_phone_number, 1, $lenth);//去掉出局前缀 ,即号码最前面的一位数字
if(substr($phone_number_1,0,2)=='01' && strlen($phone_number_1)=='12')
{//外地手机号码
$new_phone_number =substr($phone_number_1, 1, strlen($phone_number_1));
}else
{//本地手机或者固话号码
$new_phone_number = $phone_number_1;
}
}else
{//出局前缀为空
if(substr($new_phone_number,0,2)=='01' && strlen($new_phone_number)=='12')
{//外地手机号码
$new_phone_number =substr($new_phone_number, 1, strlen($new_phone_number));
}else
{//本地手机或者固话号码
$new_phone_number = $new_phone_number;
}
}
}
自己写的判断逻辑,希望对一些朋友有所帮助!