You are here

function cck_phone_countrycodes in Phone Number 6

Same name and namespace in other branches
  1. 7 cck_phone_countrycodes.inc \cck_phone_countrycodes()

Get all the country codes for supported countries.

Parameters

$cc: Optional, two character country code. If this is ommitted all country codes will be returned.

Return value

If no country code is provided an array keyed by country code, values are arrays with a 'country' and 'code' values. If an invalid $cc is provided, FALSE will be returned. If the country code is valid the country code for that country will be returned.

11 calls to cck_phone_countrycodes()
au_formatter_default in includes/phone.au.inc
Default formatter for Australian phone number.
cck_phone_field_settings in ./cck_phone.module
Implementation of hook_field_settings().
CC_formatter_default in includes/API.php
Default formatter for international phone number.
gb_formatter_default in includes/phone.gb.inc
Default formatter for international phone number.
my_formatter_default in includes/phone.my.inc
Default formatter for international phone number.

... See full list

1 string reference to 'cck_phone_countrycodes'
cck_phone.crud_input.test in tests/cck_phone.crud_input.test
Testing CRUD API for user input.

File

./cck_phone_countrycodes.inc, line 21
Defines country codes for Phone Number. Provide country name and international codes per country codes.

Code

function cck_phone_countrycodes($cc = NULL) {

  // Alpha-2 codes from ISO 3166-1 http://en.wikipedia.org/wiki/ISO_3166-1
  // Country codes from http://en.wikipedia.org/wiki/Country_calling_code
  static $country_code;
  if (!isset($country_code)) {
    $country_code = array(
      'af' => array(
        'country' => t('Afghanistan'),
        'code' => '+93',
      ),
      'al' => array(
        'country' => t('Albania'),
        'code' => '+355',
      ),
      'dz' => array(
        'country' => t('Algeria'),
        'code' => '+213',
      ),
      'as' => array(
        'country' => t('American Samoa'),
        'code' => '+1',
      ),
      'ad' => array(
        'country' => t('Andorra'),
        'code' => '+376',
      ),
      'ao' => array(
        'country' => t('Angola'),
        'code' => '+244',
      ),
      'ai' => array(
        'country' => t('Anguilla'),
        'code' => '+1',
      ),
      'ag' => array(
        'country' => t('Antigua and Barbuda'),
        'code' => '+1',
      ),
      'ar' => array(
        'country' => t('Argentina'),
        'code' => '+54',
      ),
      'am' => array(
        'country' => t('Armenia'),
        'code' => '+374',
      ),
      'aw' => array(
        'country' => t('Aruba'),
        'code' => '+297',
      ),
      'au' => array(
        'country' => t('Australia'),
        'code' => '+61',
      ),
      'at' => array(
        'country' => t('Austria'),
        'code' => '+43',
      ),
      'az' => array(
        'country' => t('Azerbaijan'),
        'code' => '+994',
      ),
      'bs' => array(
        'country' => t('Bahamas, The'),
        'code' => '+1',
      ),
      'bh' => array(
        'country' => t('Bahrain'),
        'code' => '+973',
      ),
      'bd' => array(
        'country' => t('Bangladesh'),
        'code' => '+880',
      ),
      'bb' => array(
        'country' => t('Barbados'),
        'code' => '+1',
      ),
      'by' => array(
        'country' => t('Belarus'),
        'code' => '+375',
      ),
      'be' => array(
        'country' => t('Belgium'),
        'code' => '+32',
      ),
      'bz' => array(
        'country' => t('Belize'),
        'code' => '+501',
      ),
      'bj' => array(
        'country' => t('Benin'),
        'code' => '+229',
      ),
      'bm' => array(
        'country' => t('Bermuda'),
        'code' => '+1',
      ),
      'bt' => array(
        'country' => t('Bhutan'),
        'code' => '+975',
      ),
      'bo' => array(
        'country' => t('Bolivia'),
        'code' => '+591',
      ),
      'ba' => array(
        'country' => t('Bosnia and Herzegovina'),
        'code' => '+387',
      ),
      'bw' => array(
        'country' => t('Botswana'),
        'code' => '+267',
      ),
      'br' => array(
        'country' => t('Brazil'),
        'code' => '+55',
      ),
      'io' => array(
        'country' => t('British Indian Ocean Territory'),
        'code' => '+246',
      ),
      'vg' => array(
        'country' => t('British Virgin Islands'),
        'code' => '+1',
      ),
      'bn' => array(
        'country' => t('Brunei'),
        'code' => '+673',
      ),
      'bg' => array(
        'country' => t('Bulgaria'),
        'code' => '+359',
      ),
      'bf' => array(
        'country' => t('Burkina Faso'),
        'code' => '+226',
      ),
      'bi' => array(
        'country' => t('Burundi'),
        'code' => '+257',
      ),
      'kh' => array(
        'country' => t('Cambodia'),
        'code' => '+855',
      ),
      'cm' => array(
        'country' => t('Cameroon'),
        'code' => '+237',
      ),
      'ca' => array(
        'country' => t('Canada'),
        'code' => '+1',
      ),
      'cv' => array(
        'country' => t('Cape Verde'),
        'code' => '+238',
      ),
      'ky' => array(
        'country' => t('Cayman Islands'),
        'code' => '+1',
      ),
      'cf' => array(
        'country' => t('Central African Republic'),
        'code' => '+236',
      ),
      'td' => array(
        'country' => t('Chad'),
        'code' => '+235',
      ),
      'cl' => array(
        'country' => t('Chile'),
        'code' => '+56',
      ),
      'cn' => array(
        'country' => t('China'),
        'code' => '+86',
      ),
      'cx' => array(
        'country' => t('Christmas Island'),
        'code' => '+61',
      ),
      'cc' => array(
        'country' => t('Cocos-Keeling Islands'),
        'code' => '+61',
      ),
      'co' => array(
        'country' => t('Colombia'),
        'code' => '+57',
      ),
      'km' => array(
        'country' => t('Comoros'),
        'code' => '+269',
      ),
      'cg' => array(
        'country' => t('Congo, Republic of the'),
        'code' => '+242',
      ),
      'cd' => array(
        'country' => t('Congo, Democratic Republic of'),
        'code' => '+243',
      ),
      'ck' => array(
        'country' => t('Cook Islands'),
        'code' => '+682',
      ),
      'cr' => array(
        'country' => t('Costa Rica'),
        'code' => '+506',
      ),
      'hr' => array(
        'country' => t('Croatia'),
        'code' => '+385',
      ),
      'cu' => array(
        'country' => t('Cuba'),
        'code' => '+53',
      ),
      'cy' => array(
        'country' => t('Cyprus'),
        'code' => '+357',
      ),
      'cz' => array(
        'country' => t('Czech Republic'),
        'code' => '+420',
      ),
      'dk' => array(
        'country' => t('Denmark'),
        'code' => '+45',
      ),
      'dj' => array(
        'country' => t('Djibouti'),
        'code' => '+253',
      ),
      'dm' => array(
        'country' => t('Dominica'),
        'code' => '+1',
      ),
      'do' => array(
        'country' => t('Dominican Republic'),
        'code' => '+1',
      ),
      'tp' => array(
        'country' => t('East Timor'),
        'code' => '+670',
      ),
      'ec' => array(
        'country' => t('Ecuador'),
        'code' => '+593',
      ),
      'eg' => array(
        'country' => t('Egypt'),
        'code' => '+20',
      ),
      'sv' => array(
        'country' => t('El Salvador'),
        'code' => '+503',
      ),
      'gq' => array(
        'country' => t('Equatorial Guinea'),
        'code' => '+240',
      ),
      'er' => array(
        'country' => t('Eritrea'),
        'code' => '+291',
      ),
      'ee' => array(
        'country' => t('Estonia'),
        'code' => '+372',
      ),
      'et' => array(
        'country' => t('Ethiopia'),
        'code' => '+251',
      ),
      'fk' => array(
        'country' => t('Falkland Islands'),
        'code' => '+500',
      ),
      'fo' => array(
        'country' => t('Faroe Islands'),
        'code' => '+298',
      ),
      'fj' => array(
        'country' => t('Fiji'),
        'code' => '+679',
      ),
      'fi' => array(
        'country' => t('Finland'),
        'code' => '+358',
      ),
      'fr' => array(
        'country' => t('France'),
        'code' => '+33',
      ),
      'gf' => array(
        'country' => t('French Guiana'),
        'code' => '+594',
      ),
      'pf' => array(
        'country' => t('French Polynesia'),
        'code' => '+689',
      ),
      'ga' => array(
        'country' => t('Gabon'),
        'code' => '+241',
      ),
      'gm' => array(
        'country' => t('Gambia, The'),
        'code' => '+220',
      ),
      'ge' => array(
        'country' => t('Georgia'),
        'code' => '+995',
      ),
      'de' => array(
        'country' => t('Germany'),
        'code' => '+49',
      ),
      'gh' => array(
        'country' => t('Ghana'),
        'code' => '+233',
      ),
      'gi' => array(
        'country' => t('Gibraltar'),
        'code' => '+350',
      ),
      'gr' => array(
        'country' => t('Greece'),
        'code' => '+30',
      ),
      'gl' => array(
        'country' => t('Greenland'),
        'code' => '+299',
      ),
      'gd' => array(
        'country' => t('Grenada'),
        'code' => '+1',
      ),
      'gp' => array(
        'country' => t('Guadeloupe'),
        'code' => '+590',
      ),
      'gu' => array(
        'country' => t('Guam'),
        'code' => '+1',
      ),
      'gt' => array(
        'country' => t('Guatemala'),
        'code' => '+502',
      ),
      'gn' => array(
        'country' => t('Guinea'),
        'code' => '+224',
      ),
      'gw' => array(
        'country' => t('Guinea-Bissau'),
        'code' => '+245',
      ),
      'gy' => array(
        'country' => t('Guyana'),
        'code' => '+592',
      ),
      'ht' => array(
        'country' => t('Haiti'),
        'code' => '+509',
      ),
      'hn' => array(
        'country' => t('Honduras'),
        'code' => '+504',
      ),
      'hk' => array(
        'country' => t('Hong Kong'),
        'code' => '+852',
      ),
      'hu' => array(
        'country' => t('Hungary'),
        'code' => '+36',
      ),
      'is' => array(
        'country' => t('Iceland'),
        'code' => '+354',
      ),
      'in' => array(
        'country' => t('India'),
        'code' => '+91',
      ),
      'id' => array(
        'country' => t('Indonesia'),
        'code' => '+62',
      ),
      'ir' => array(
        'country' => t('Iran'),
        'code' => '+98',
      ),
      'iq' => array(
        'country' => t('Iraq'),
        'code' => '+964',
      ),
      'ie' => array(
        'country' => t('Ireland'),
        'code' => '+353',
      ),
      'il' => array(
        'country' => t('Israel'),
        'code' => '+972',
      ),
      'it' => array(
        'country' => t('Italy'),
        'code' => '+39',
      ),
      'ci' => array(
        'country' => t('Ivory Coast'),
        'code' => '+225',
      ),
      'jm' => array(
        'country' => t('Jamaica'),
        'code' => '+1',
      ),
      'jp' => array(
        'country' => t('Japan'),
        'code' => '+81',
      ),
      'jo' => array(
        'country' => t('Jordan'),
        'code' => '+962',
      ),
      'kz' => array(
        'country' => t('Kazakhstan'),
        'code' => '+7',
      ),
      'ke' => array(
        'country' => t('Kenya'),
        'code' => '+254',
      ),
      'ki' => array(
        'country' => t('Kiribati'),
        'code' => '+686',
      ),
      'kw' => array(
        'country' => t('Kuwait'),
        'code' => '+965',
      ),
      'kg' => array(
        'country' => t('Kyrgyzstan'),
        'code' => '+996',
      ),
      'la' => array(
        'country' => t('Laos'),
        'code' => '+856',
      ),
      'lv' => array(
        'country' => t('Latvia'),
        'code' => '+371',
      ),
      'lb' => array(
        'country' => t('Lebanon'),
        'code' => '+961',
      ),
      'ls' => array(
        'country' => t('Lesotho'),
        'code' => '+266',
      ),
      'lr' => array(
        'country' => t('Liberia'),
        'code' => '+231',
      ),
      'ly' => array(
        'country' => t('Libya'),
        'code' => '+218',
      ),
      'li' => array(
        'country' => t('Liechtenstein'),
        'code' => '+423',
      ),
      'lt' => array(
        'country' => t('Lithuania'),
        'code' => '+370',
      ),
      'lu' => array(
        'country' => t('Luxembourg'),
        'code' => '+352',
      ),
      'mo' => array(
        'country' => t('Macau'),
        'code' => '+853',
      ),
      'mk' => array(
        'country' => t('Macedonia'),
        'code' => '+389',
      ),
      'mg' => array(
        'country' => t('Madagascar'),
        'code' => '+261',
      ),
      'mw' => array(
        'country' => t('Malawi'),
        'code' => '+265',
      ),
      'my' => array(
        'country' => t('Malaysia'),
        'code' => '+60',
      ),
      'mv' => array(
        'country' => t('Maldives'),
        'code' => '+960',
      ),
      'ml' => array(
        'country' => t('Mali'),
        'code' => '+223',
      ),
      'mt' => array(
        'country' => t('Malta'),
        'code' => '+356',
      ),
      'mh' => array(
        'country' => t('Marshall Islands'),
        'code' => '+692',
      ),
      'mq' => array(
        'country' => t('Martinique'),
        'code' => '+596',
      ),
      'mr' => array(
        'country' => t('Mauritania'),
        'code' => '+222',
      ),
      'mu' => array(
        'country' => t('Mauritius'),
        'code' => '+230',
      ),
      'yt' => array(
        'country' => t('Mayotte'),
        'code' => '+269',
      ),
      'mx' => array(
        'country' => t('Mexico'),
        'code' => '+52',
      ),
      'fm' => array(
        'country' => t('Micronesia, Federated States of'),
        'code' => '+691',
      ),
      'md' => array(
        'country' => t('Moldova'),
        'code' => '+373',
      ),
      'mc' => array(
        'country' => t('Monaco'),
        'code' => '+377',
      ),
      'mn' => array(
        'country' => t('Mongolia'),
        'code' => '+976',
      ),
      'me' => array(
        'country' => t('Montenegro'),
        'code' => '+382',
      ),
      'ms' => array(
        'country' => t('Montserrat'),
        'code' => '+1',
      ),
      'ma' => array(
        'country' => t('Morocco'),
        'code' => '+212',
      ),
      'mz' => array(
        'country' => t('Mozambique'),
        'code' => '+258',
      ),
      'mm' => array(
        'country' => t('Myanmar'),
        'code' => '+95',
      ),
      'na' => array(
        'country' => t('Namibia'),
        'code' => '+264',
      ),
      'nr' => array(
        'country' => t('Nauru'),
        'code' => '+674',
      ),
      'np' => array(
        'country' => t('Nepal'),
        'code' => '+977',
      ),
      'nl' => array(
        'country' => t('Netherlands'),
        'code' => '+31',
      ),
      'an' => array(
        'country' => t('Netherlands Antilles'),
        'code' => '+599',
      ),
      'nc' => array(
        'country' => t('New Caledonia'),
        'code' => '+687',
      ),
      'nz' => array(
        'country' => t('New Zealand'),
        'code' => '+64',
      ),
      'ni' => array(
        'country' => t('Nicaragua'),
        'code' => '+505',
      ),
      'ne' => array(
        'country' => t('Niger'),
        'code' => '+227',
      ),
      'ng' => array(
        'country' => t('Nigeria'),
        'code' => '+234',
      ),
      'nu' => array(
        'country' => t('Niue'),
        'code' => '+683',
      ),
      'nf' => array(
        'country' => t('Norfolk Island'),
        'code' => '+672',
      ),
      'kp' => array(
        'country' => t('North Korea'),
        'code' => '+850',
      ),
      'mp' => array(
        'country' => t('Northern Mariana Islands'),
        'code' => '+1',
      ),
      'no' => array(
        'country' => t('Norway'),
        'code' => '+47',
      ),
      'om' => array(
        'country' => t('Oman'),
        'code' => '+968',
      ),
      'pk' => array(
        'country' => t('Pakistan'),
        'code' => '+92',
      ),
      'pw' => array(
        'country' => t('Palau'),
        'code' => '+680',
      ),
      'ps' => array(
        'country' => t('Palestine'),
        'code' => '+970',
      ),
      'pa' => array(
        'country' => t('Panama'),
        'code' => '+507',
      ),
      'pg' => array(
        'country' => t('Papua New Guinea'),
        'code' => '+675',
      ),
      'py' => array(
        'country' => t('Paraguay'),
        'code' => '+595',
      ),
      'pe' => array(
        'country' => t('Peru'),
        'code' => '+51',
      ),
      'ph' => array(
        'country' => t('Philippines'),
        'code' => '+63',
      ),
      'pl' => array(
        'country' => t('Poland'),
        'code' => '+48',
      ),
      'pt' => array(
        'country' => t('Portugal'),
        'code' => '+351',
      ),
      'pr' => array(
        'country' => t('Puerto Rico'),
        'code' => '+1',
      ),
      'qa' => array(
        'country' => t('Qatar'),
        'code' => '+974',
      ),
      'ro' => array(
        'country' => t('Romania'),
        'code' => '+40',
      ),
      'ru' => array(
        'country' => t('Russia'),
        'code' => '+7',
      ),
      'rw' => array(
        'country' => t('Rwanda'),
        'code' => '+250',
      ),
      'sh' => array(
        'country' => t('Saint Helena'),
        'code' => '+290',
      ),
      'kn' => array(
        'country' => t('Saint Kitts and Nevis'),
        'code' => '+1',
      ),
      'lc' => array(
        'country' => t('Saint Lucia'),
        'code' => '+1',
      ),
      'pm' => array(
        'country' => t('Saint Pierre and Miquelon'),
        'code' => '+508',
      ),
      'vc' => array(
        'country' => t('Saint Vincent and the Grenadines'),
        'code' => '+1',
      ),
      'ws' => array(
        'country' => t('Samoa'),
        'code' => '+1',
      ),
      'sm' => array(
        'country' => t('San Marino'),
        'code' => '+378',
      ),
      'st' => array(
        'country' => t('Sao Tome and Principe'),
        'code' => '+239',
      ),
      'sa' => array(
        'country' => t('Saudi Arabia'),
        'code' => '+966',
      ),
      'sn' => array(
        'country' => t('Senegal'),
        'code' => '+221',
      ),
      'rs' => array(
        'country' => t('Serbia'),
        'code' => '+381',
      ),
      'sc' => array(
        'country' => t('Seychelles'),
        'code' => '+248',
      ),
      'sl' => array(
        'country' => t('Sierra Leone'),
        'code' => '+232',
      ),
      'sg' => array(
        'country' => t('Singapore'),
        'code' => '+65',
      ),
      'sk' => array(
        'country' => t('Slovakia'),
        'code' => '+421',
      ),
      'si' => array(
        'country' => t('Slovenia'),
        'code' => '+386',
      ),
      'sb' => array(
        'country' => t('Solomon Islands'),
        'code' => '+677',
      ),
      'so' => array(
        'country' => t('Somalia'),
        'code' => '+252',
      ),
      'za' => array(
        'country' => t('South Africa'),
        'code' => '+27',
      ),
      'kr' => array(
        'country' => t('South Korea'),
        'code' => '+82',
      ),
      'ss' => array(
        'country' => t('South Sudan'),
        'code' => '+211',
      ),
      'es' => array(
        'country' => t('Spain'),
        'code' => '+34',
      ),
      'lk' => array(
        'country' => t('Sri Lanka'),
        'code' => '+94',
      ),
      'sd' => array(
        'country' => t('Sudan'),
        'code' => '+249',
      ),
      'sr' => array(
        'country' => t('Suriname'),
        'code' => '+597',
      ),
      'sz' => array(
        'country' => t('Swaziland'),
        'code' => '+268',
      ),
      'se' => array(
        'country' => t('Sweden'),
        'code' => '+46',
      ),
      'ch' => array(
        'country' => t('Switzerland'),
        'code' => '+41',
      ),
      'sy' => array(
        'country' => t('Syria'),
        'code' => '+963',
      ),
      'tw' => array(
        'country' => t('Taiwan'),
        'code' => '+886',
      ),
      'tj' => array(
        'country' => t('Tajikistan'),
        'code' => '+992',
      ),
      'tz' => array(
        'country' => t('Tanzania'),
        'code' => '+255',
      ),
      'th' => array(
        'country' => t('Thailand'),
        'code' => '+66',
      ),
      'tg' => array(
        'country' => t('Togo'),
        'code' => '+228',
      ),
      'tk' => array(
        'country' => t('Tokelau'),
        'code' => '+690',
      ),
      'to' => array(
        'country' => t('Tonga'),
        'code' => '+676',
      ),
      'tt' => array(
        'country' => t('Trinidad and Tobago'),
        'code' => '+1',
      ),
      'tn' => array(
        'country' => t('Tunisia'),
        'code' => '+216',
      ),
      'tr' => array(
        'country' => t('Turkey'),
        'code' => '+90',
      ),
      'tm' => array(
        'country' => t('Turkmenistan'),
        'code' => '+993',
      ),
      'tc' => array(
        'country' => t('Turks and Caicos Islands'),
        'code' => '+1',
      ),
      'tv' => array(
        'country' => t('Tuvalu'),
        'code' => '+688',
      ),
      'ug' => array(
        'country' => t('Uganda'),
        'code' => '+256',
      ),
      'ua' => array(
        'country' => t('Ukraine'),
        'code' => '+380',
      ),
      'ae' => array(
        'country' => t('United Arab Emirates'),
        'code' => '+971',
      ),
      'gb' => array(
        'country' => t('United Kingdom'),
        'code' => '+44',
      ),
      'us' => array(
        'country' => t('United States'),
        'code' => '+1',
      ),
      'uy' => array(
        'country' => t('Uruguay'),
        'code' => '+598',
      ),
      'vi' => array(
        'country' => t('US Virgin Islands'),
        'code' => '+1',
      ),
      'uz' => array(
        'country' => t('Uzbekistan'),
        'code' => '+998',
      ),
      'vu' => array(
        'country' => t('Vanuatu'),
        'code' => '+678',
      ),
      'va' => array(
        'country' => t('Vatican City'),
        'code' => '+39',
      ),
      've' => array(
        'country' => t('Venezuela'),
        'code' => '+58',
      ),
      'vn' => array(
        'country' => t('Vietnam'),
        'code' => '+84',
      ),
      'wf' => array(
        'country' => t('Wallis and Futuna'),
        'code' => '+681',
      ),
      'ye' => array(
        'country' => t('Yemen'),
        'code' => '+967',
      ),
      'zm' => array(
        'country' => t('Zambia'),
        'code' => '+260',
      ),
      'zw' => array(
        'country' => t('Zimbabwe'),
        'code' => '+263',
      ),
    );
  }
  if (is_null($cc)) {
    return $country_code;
  }
  elseif (isset($country_code[$cc])) {
    return $country_code[$cc];
  }
  return FALSE;
}