function format_br_phone_number in Phone 6
Same name and namespace in other branches
- 7 include/phone.br.inc \format_br_phone_number()
Formatting for Brazilian Phone Numbers.
Parameters
string $phonenumber:
Return value
string Returns a string containting the phone number with some formatting.
1 call to format_br_phone_number()
File
- ./
phone.br.inc, line 38 - CCK Field for Brazilian phone numbers. (based on CCK Field for French phone numbers.)
Code
function format_br_phone_number($phonenumber, $field = FALSE) {
$phone = str_replace(array(
' ',
'-',
'(',
')',
), '', $phonenumber);
if (preg_match(PHONE_BR_REGEX, $phone, $matches) != 1) {
return $phonenumber;
// this is possible?
}
$formatedphone = '';
if ($field && $field['phone_country_code']) {
$formatedphone .= '+55 ';
}
$formatedphone .= '(' . $matches[3] . ')';
$formatedphone .= ' ' . $matches[6] . '-';
$formatedphone .= '' . $matches[7];
return $formatedphone;
}