You are here

function valid_cl_phone_number in Phone 7

Same name and namespace in other branches
  1. 6 phone.cl.inc \valid_cl_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.cl.inc, line 21
CCK Field for Chili phone numbers.

Code

function valid_cl_phone_number($phonenumber) {

  // define regular expression
  $regex = "/^((\\(\\d{3}\\) ?)|(\\d{3}-)|(\\(\\d{2}\\) ?)|(\\d{2}-)|(\\(\\d{1}\\) ?)|(\\d{1}-))?\\d{3}-(\\d{3}|\\d{4})\$/i";

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