1、手机号整理
public function arrangement_phone($phone){
if(empty($phone)){
return false;
}
$result = '';
for($i=0;$i<strlen($phone);$i++){
if(is_numeric($phone[$i])){
$result.=$phone[$i];
}
}
return $result;
}
2、手机号验证
public function verification_phone($phone){
if(empty($phone)){
return false;
}
$verification = '/^(((13[0-9])|(14[57])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|190|197|196|192)[0-9]{8})$/';
if(!preg_match($verification,$this->arrangement_phone($phone))){
return false;
}
return true;
}