Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in

Posted on

Php Validate international phone number using regex

function validatePhoneNumber($phoneNumber) {
  $regex = '/^\+?[0-9]{1,3}\s?\(?[0-9]{3}\)?[-\s]?[0-9]{3}[-\s]?[0-9]{4}$/';
  if (preg_match($regex, $phoneNumber)) {
    return true;
  } else {
    return false;

$result = validatePhoneNumber('+1 (555) 555-5555');

echo $result; //true

Enter fullscreen mode Exit fullscreen mode

Top comments (0)