function gb_formatter_local in Phone Number 6
Same name and namespace in other branches
- 7 includes/phone.gb.inc \gb_formatter_local()
Local formatter for local phone number.
Parameters
$element: $element['#item']['country_codes']: alpha-2 country code $element['#item']['number']: phone number
$error: The error message to shown to user. Available parameters to use in the error message are
- "%countrycode": the alpha-2 CC
- "%phone_input": the original number input by user (could be invalid)
- "%max_length": allowed maximum length of the phone number
Return value
boolean TRUE if it is a valid phone number for that country, FALSE otherwise.
File
- includes/
phone.gb.inc, line 110 - CCK Field for United Kingdom phone numbers.
Code
function gb_formatter_local($element) {
// Display a local phone number without country code.
$phone = '';
$number = $element['#item']['number'];
if ($number) {
if (preg_match(_uk_phone_rules(), $number, $matches)) {
// output as 0AA BBBB CCCC, 0AAA BBB CCCC or 0AAAA BBB CCC
array_shift($matches);
$phone = '0' . implode(' ', $matches);
}
else {
$phone = "0{$number}";
}
}
return $phone;
}