Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- public function validateMobile($mobile)
- {
- $dddsBrazil = array_merge(
- range(11, 19),
- [21,22,24,27,28,],
- range(31,35),
- [37,38,],
- range(41, 49),
- [51,53,54,55,],
- range(61, 69),
- [71,73,74,75,77,79,],
- range(81, 89),
- range(91, 99)
- );
- $cleanNumber = preg_replace('/[^0-9]/','', $mobile);
- $mobileDdd = substr($cleanNumber, 0, 2);
- // Has a valid ddd number?
- if (!in_array($mobileDdd, $dddsBrazil)) {
- return false;
- }
- if (!in_array(strlen($cleanNumber), [10,11]) ) {
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement