function _telephone_validation_get_country_codes in Telephone Validation 7
Get list of all available countries with codes.
Return value
array Returns list of all countries from iso.inc file cross referenced with available country codes.
1 call to _telephone_validation_get_country_codes()
File
- ./
telephone_validation.module, line 172 - Validate phone number.
Code
function _telephone_validation_get_country_codes() {
include_once DRUPAL_ROOT . '/includes/iso.inc';
$phone_util = \libphonenumber\PhoneNumberUtil::getInstance();
$regions = array();
foreach (_country_get_predefined_list() as $region => $name) {
$region_meta = $phone_util
->getMetadataForRegion($region);
if (is_object($region_meta)) {
$regions[$region] = $name . ' - +' . $region_meta
->getCountryCode() . ' ' . $region_meta
->getLeadingDigits();
}
}
return $regions;
}