You are here

function valid_ru_phone_number in Phone 6

Same name and namespace in other branches
  1. 5 phone.ru.inc \valid_ru_phone_number()
  2. 7 include/phone.ru.inc \valid_ru_phone_number()

Verifies that $phonenumber is a valid ten-digit Russian phone number

Parameters

string $phonenumber:

Return value

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

File

./phone.ru.inc, line 23
CCK Field for Russian phone numbers.

Code

function valid_ru_phone_number($phonenumber) {

  //$phonenumber = trim($phonenumber);

  // define regular expression
  $regex = "/\n    \\D*           # ignore non-digits\n    [78]?         # an optional 78\n    \\D*           # optional separator\n    \\d{3,5}       # area code 3-5 digit\n    \\D*           # optional separator\n    \\d{1,3}       # 3-digit prefix\n    \\D*           # optional separator\n    \\d{2}         # 2-digit line number\n    \\D*           # optional separator\n    \\d{2}         # 2-digit line number\n    \\D*           # ignore trailing non-digits\n    /x";

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