当前位置:网站首页>PHP extracts the phone number in the string and verifies whether it is 11 digits
PHP extracts the phone number in the string and verifies whether it is 11 digits
2022-07-21 20:51:00 【It's Anbin】
Suppose there is a mobile number 13632869999 Mixed in a pile of strings , You can use the following methods to get the phone number .
$phone = ' Ha ha ha ha ha ha aaaaaaaa13632869999aaaabbbbbbbbbbbccccccccc Happy happy ';
if (!is_numeric($phone)) { // If it is a non pure digital mobile number Start filtering
if(preg_match('/\d+/',$phone,$arr)){ // Filter to get pure numbers
$phone = $arr[0];
if(!preg_match("/^1[34578]{1}\d{9}$/",$phone)){ // Judge whether the pure number is normal 11 Cell phone number
return ' Not 11 Cell phone number !';
}else{
return $phone;
}
}
}
边栏推荐
- Simple method of array de duplication (excluding reference type)
- Boundary layer integral equation and Marangoni effect
- web安全--文件上传中间件解析漏洞
- Large file upload (in G) JS part
- nodejs使用POST方法接收js对象并写入json文件
- thinkphp5.1下使用 jwt 进行验证
- php(tp框架)使用阿里云OSS存储
- thinkphp设置单位时间内限制 ip 的请求
- 大文件下载 解决方案
- 18. [precautions for pointer pointing to two-dimensional array]
猜你喜欢
Simple method of array de duplication (excluding reference type)
phpmyadmin后台文件包含漏洞分析
The text file is transferred to the external server through the web proxy server and returned after modification
【极客大挑战 2019】Easy,Love,Baby-SQL
BUUCTF(misc)
10. [file opening format and its determination of whether to open]
DWVA[SQL-Injection]学习记录
网页服务器/客户端搭建(nodejs启动exe程序)
24. [judge whether it is an integer with bytes]
First Working Day~
随机推荐
JS converts hexadecimal color to RGBA format
Redis与memcached有何不同
Planned tasks under laravel5.1
Lazy loading of pictures
XML parsing
Nvm、Nrm使用教程
DVWA[SQL-Injection(Blind)]学习记录
Openfoam tips
The content of vant toast has been overwritten by the first trigger
Recommend a useful WYSIWYG markdown editor mark text
固体火箭发动机零维内弹道方程组
JWT实现TP5用户登陆功能
Nodejs waits for a period of time
h5在线聊天室
DWVA[SQL-Injection]学习记录
Common formula for matrix derivation (avoiding pit) + derivation of matrix modulus and absolute value
推荐一个好用的 所见即所得的 markdown 编辑器 Mark Text
JS将16进制颜色转为rgba格式
Wechat applet makes a slot machine lottery animation
通过Web代理服务器实现文本文件传输至外部服务器并且修改后返回