Skip to content

Instantly share code, notes, and snippets.

@coder-liyang
Created November 7, 2016 07:32
Show Gist options
  • Select an option

  • Save coder-liyang/8bda78a62d2ce427d760d295a8c34ad4 to your computer and use it in GitHub Desktop.

Select an option

Save coder-liyang/8bda78a62d2ce427d760d295a8c34ad4 to your computer and use it in GitHub Desktop.
判断手机号的运营商
/**
* 判断手机号的类型
* 更新时间 2016-11-07
* @param $mobile
* @return int 1:电信 2:移动 3:联通 4:虚拟运营商 10:未知
*/
function getMobileType($mobile){
$prefix = substr($mobile,0,3);
if (in_array($prefix, array('133','153','154','181','180','189','177'))) {
return 1;
} elseif (in_array($prefix, array('134','135','136','137','138','139','147','150','151','152','157','158','159','178','182','183','184','187','188'))) {
return 2;
} elseif (in_array($prefix, array('130','131','132','155','156','185','186','145','176'))) {
return 3;
} elseif (in_array($prefix, array('170','177'))) {
return 4;
} else {
return 10;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment