You are here

function format_phone_number in Phone 7

Same name and namespace in other branches
  1. 5 phone.module \format_phone_number()
  2. 6 phone.module \format_phone_number()

Formatting for Phone Numbers.

Parameters

string $countrycode:

string $phonenumber:

Return value

boolean Returns boolean FALSE if the phone number is not valid.

6 calls to format_phone_number()
ILPhoneNumberTestCase::testPhoneILFormatting in tests/phone.il.test
NZPhoneNumberTestCase::testPhoneNZFormatting in tests/phone.nz.test
PhoneIntTest::assertConversion in tests/phone.int.test
PhonePanamanianTest::testFormattingPanamenianPhoneNumber in tests/phone.pa.test
phone_field_presave in ./phone.module
Implements hook_field_presave().

... See full list

File

./phone.module, line 370

Code

function format_phone_number($countrycode, $phonenumber, $field) {
  $countrycode = trim($countrycode);
  $phonenumber = trim($phonenumber);
  if (phone_supported_countrycode($countrycode)) {
    $format_phone_function = 'format_' . $countrycode . '_phone_number';
    module_load_include('inc', 'phone', 'include/phone.' . $countrycode);
    if (function_exists($format_phone_function)) {
      return $format_phone_function($phonenumber, $field);
    }
  }

  //Country not taken into account yet
  return FALSE;
}