You are here

function valid_sg_phone_number in Phone 7

Same name and namespace in other branches
  1. 6 phone.sg.inc \valid_sg_phone_number()

Verifies that $phonenumber is valid

Parameters

string $phonenumber:

Return value

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

File

include/phone.sg.inc, line 21
CCK Field for Singapore phone numbers.

Code

function valid_sg_phone_number($phonenumber) {

  // define regular expression

  /*
    See: http://en.wikipedia.org/wiki/Telephone_numbers_in_Singapore

    Accepts:
        +6561234567  / +6581234567  / +6591234567
        +65 61234567 / +65 81234567 / +65 91234567
        61234567     / 81234567     / 91234567
  */
  $regex = '/^(\\+65)?\\s?[689]\\d{7}$/i';

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