You are here

function format_sn_phone_number in Phone 7

Formatting for Senegalese Phone Numbers.

Parameters

string $phonenumber:

Return value

string Returns the phone number as string.

File

include/phone.sn.inc, line 36
CCK Field for Senegalese phone numbers.

Code

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

    // not a french phone number
  }

  //
  if (in_array($matches[0], array(
    '+221',
    '00221',
  ))) {
    return $matches[2];
  }
  else {
    return $matches[0];
  }
}