You are here

function format_hu_phone_number in Phone 7

Same name and namespace in other branches
  1. 6 phone.hu.inc \format_hu_phone_number()

Convert a valid Hungarian phone number into standard (+36) ..... format

Parameters

$phonenumber must be a valid nine-digit number (with optional international prefix):

File

include/phone.hu.inc, line 37
CCK Field for Hungarian phone numbers.

Code

function format_hu_phone_number($phonenumber, $field = FALSE) {
  $phonenumber = trim($phonenumber);

  // get digits of phone number
  preg_match(PHONE_HU_REGEX, $phonenumber, $matches);
  $formatedphone = '';
  if ($field && $field['phone_country_code']) {
    $formatedphone .= '+36 ';
  }

  // construct ten-digit phone number
  $formatedphone .= $matches[2] . ' ' . $matches[3] . ' ' . $matches[4];
  return $formatedphone;
}