You are here

function _normalize_country_code in Phone 6

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

Adds a country code to a phone number if necessary.

Parameters

$phonenumber: International or local phone number to format

Return value

International phone number with country code

2 calls to _normalize_country_code()
format_int_phone_number in ./phone.int.inc
Formats $phonenumber into the standard representation of international numbers as per E.123.
valid_int_phone_number in ./phone.int.inc
Verifies that $phonenumber is a valid international phone number as per ITU or, if a default country code is specified, a valid subscriber number.

File

./phone.int.inc, line 109

Code

function _normalize_country_code($phonenumber, $field = array()) {
  if ($phonenumber[0] !== '+') {
    $cc = isset($field['phone_default_country_code']) ? $field['phone_default_country_code'] : '1';
    return "+{$cc} {$phonenumber}";
  }
  return $phonenumber;
}