function _normalize_country_code in Phone 7
Same name and namespace in other branches
- 6 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 include/
phone.int.inc - Formats $phonenumber into the standard representation of international numbers as per E.123.
- valid_int_phone_number in include/
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
- include/
phone.int.inc, line 116
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;
}