You are here

function valid_es_phone_number in Phone 5

Same name and namespace in other branches
  1. 6 phone.es.inc \valid_es_phone_number()
  2. 7 include/phone.es.inc \valid_es_phone_number()

Verifies that $phonenumber is a valid nine-digit Spanish phone number

Parameters

string $phonenumber:

Return value

boolean Returns boolean FALSE if the phone number is not valid.

File

./phone.es.inc, line 9

Code

function valid_es_phone_number($phonenumber) {

  //$phonenumber = trim($phonenumber);

  // define regular expression
  $regex = "/\n    \\D*           # optional separator \n    [69]\\d{2}     # first group of numbers\n    \\D*           # optional separator\n    \\d{3}         # second group\n    \\D*           # optional separator\n    \\d{3}         # third group\n    \\D*           # ignore trailing non-digits\n    \$/x";

  // return true if valid, false otherwise
  return (bool) preg_match($regex, $phonenumber);
}