You are here

function format_fr_phone_number in Phone 6

Same name and namespace in other branches
  1. 5 phone.fr.inc \format_fr_phone_number()
  2. 7 include/phone.fr.inc \format_fr_phone_number()

Formatting for French Phone Numbers.

Parameters

string $phonenumber:

Return value

string Returns a string containting the phone number with some formatting.

1 call to format_fr_phone_number()
PhoneFrenchTest::testPhoneFRFormatting in tests/phone-fr.test

File

./phone.fr.inc, line 40
CCK Field for French phone numbers.

Code

function format_fr_phone_number($phonenumber, $field = FALSE) {
  $phone = str_replace(array(
    ' ',
    '-',
    '(',
    ')',
  ), '', $phonenumber);
  if (preg_match(PHONE_FR_REGEX, $phone, $matches) != 1) {
    return $phonenumber;

    // not a french phone number
  }
  return ($field && $field['phone_country_code'] ? '+33 ' : '0') . $matches[2];
}