You are here

function valid_hu_phone_number in Phone 6

Same name and namespace in other branches
  1. 7 include/phone.hu.inc \valid_hu_phone_number()

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

Parameters

string $phonenumber:

Return value

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

File

./phone.hu.inc, line 22
CCK Field for Hungarian phone numbers.

Code

function valid_hu_phone_number($phonenumber) {

  //$phonenumber = trim($phonenumber);

  // define regular expression
  $regex = "/\n    \\D*           # optional separator\n\t(?:\\+?36|06)? # country code\n    (\\d\\d?)       # area code\n    \\D*           # optional separator\n    (\\d{3})       # second group\n    \\D*           # optional separator\n    (\\d{3,4})     # third group\n    \\D*           # ignore trailing non-digits\n    \$/x";

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