/** * 判断手机号的类型 * 更新时间 2016-11-07 * @param $mobile * @return int 1:电信 2:移动 3:联通 4:虚拟运营商 10:未知 */ public static int getMobileType(String $mobile){ String $prefix = $mobile.substring(0, 3); String telcomm [] = new String[]{"133","153","154","181","180","189","177"}; String mobilecomm [] = new String[]{"134","135","136","137","138","139","147","150","151","152","157","158","159","178","182","183","184","187","188"}; String unioncomm [] = new String[]{"130","131","132","155","156","185","186","145","176"}; String virtualcomm [] = new String[]{"170","177"}; if(Arrays.asList(telcomm).contains($prefix)) return 1; else if(Arrays.asList(mobilecomm).contains($prefix)) return 2; else if (Arrays.asList(unioncomm).contains($prefix)) return 3; else if (Arrays.asList(virtualcomm).contains($prefix)) return 4; else return 10; } }
本博客文章绝大多数为原创,少量为转载,代码经过测试验证,如果有疑问直接留言或者私信我。
创作文章不容易,转载文章必须注明文章出处;如果这篇文章对您有帮助,点击右侧打赏,支持一下吧。
创作文章不容易,转载文章必须注明文章出处;如果这篇文章对您有帮助,点击右侧打赏,支持一下吧。