You are here

function valid_pk_phone_number in Phone 6

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

Verifies that $phonenumber is valid

Parameters

string $phonenumber:

Return value

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

File

./phone.pk.inc, line 22
CCK Field for Pakistanese phone numbers.

Code

function valid_pk_phone_number($phonenumber) {

  // define regular expression
  $regex = "/^(\\+)?([9]{1}[2]{1})?-? ?(\\()?([0]{1})?[1-9]{2,4}(\\))?-? ??(\\()?[1-9]{4,7}(\\))?\$/i";

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