<?php

/* Often we need to store countries in our database, or
 * offer a drop-down list. Here is the data we need to do
 * that! 
 */

$d =
"AF,AFG,Afghanistan
AL,ALB,Albania
DZ,DZA,Algeria
AS,ASM,American Samoa
AD,AND,Andorra
AO,AGO,Angola
AI,AIA,Anguilla
AQ,ATA,Antarctica
AG,ATG,Antigua and Barbuda
AR,ARG,Argentina
AM,ARM,Armenia
AW,ABW,Aruba
AU,AUS,Australia
AT,AUT,Austria
AZ,AZE,Azerbaijan
BS,BHS,Bahamas
BH,BHR,Bahrain
BD,BGD,Bangladesh
BB,BRB,Barbados
BY,BLR,Belarus
BE,BEL,Belgium
BZ,BLZ,Belize
BJ,BEN,Benin
BM,BMU,Bermuda
BT,BTN,Bhutan
BO,BOL,Bolivia
BA,BIH,Bosnia and Herzegovina
BW,BWA,Botswana
BV,BVT,Bouvet Island
BR,BRA,Brazil
IO,IOT,British Indian Ocean Territory
BN,BRN,Brunei Darussalam
BG,BGR,Bulgaria
BF,BFA,Burkina Faso
BI,BDI,Burundi
KH,KHM,Cambodia
CM,CMR,Cameroon
CA,CAN,Canada
CV,CPV,Cape Verde
KY,CYM,Cayman Islands
CF,CAF,Central African Republic
TD,TCD,Chad
CL,CHL,Chile
CN,CHN,China
CX,CXR,Christmas Island
CC,CCK,Cocos (Keeling) Islands
CO,COL,Colombia
KM,COM,Comoros
CD,COD,Congo, Democratic Republic of the
CG,COG,Congo (Congo-Brazzaville)
CK,COK,Cook Islands
CR,CRI,Costa Rica
CI,CIV,Cote D'ivoire
HR,HRV,Croatia (Hrvatska)
CU,CUB,Cuba
CY,CYP,Cyprus
CZ,CZE,Czech Republic
DK,DNK,Denmark
DJ,DJI,Djibouti
DM,DMA,Dominica
DO,DOM,Dominican Republic
TP,TMP,East Timor
EC,ECU,Ecuador
EG,EGY,Egypt
SV,SLV,El Salvador
GQ,GNQ,Equatorial Guinea
ER,ERI,Eritrea
EE,EST,Estonia
ET,ETH,Ethiopia
FO,FRO,Faroe Islands
FK,FLK,Falkland Islands (Malvinas)
FJ,FJI,Fiji
FI,FIN,Finland
FR,FRA,France
GF,GUF,French Guiana
PF,PYF,French Polynesia
TF,ATF,French Southern Territories
GA,GAB,Gabon
GM,GMB,Gambia
GE,GEO,Georgia
DE,DEU,Germany
GH,GHA,Ghana
GI,GIB,Gibraltar
GR,GRC,Greece
GL,GRL,Greenland
GD,GRD,Grenada
GP,GLP,Guadeloupe
GU,GUM,Guam
GT,GTM,Guatemala
GN,GIN,Guinea
GW,GNB,Guinea-Bissau
GY,GUY,Guyana
HT,HTI,Haiti
HM,HMD,Heard And McDonald Islands
VA,VAT,Holy See (Vatican City State)
HN,HND,Honduras
HK,HKG,Hong Kong
HU,HUN,Hungary
IS,ISL,Iceland
IN,IND,India
ID,IDN,Indonesia
IR,IRN,Iran (Islamic Republic Of)
IQ,IRQ,Iraq
IE,IRL,Ireland
IL,ISR,Israel
IT,ITA,Italy
JM,JAM,Jamaica
JP,JPN,Japan
JO,JOR,Jordan
KZ,KAZ,Kazakhstan
KE,KEN,Kenya
KI,KIR,Kiribati
KP,PKR,Korea, Democratic People's Republic of
KR,KOR,Korea, Republic of
KW,KWT,Kuwait
KG,KGZ,Kyrgyzstan
LA,LAO,Lao People's Democratic Republic
LV,LVA,Latvia
LB,LBN,Lebanon
LS,LSO,Lesotho
LR,LBR,Liberia
LY,LBY,Libyan Arab Jamahiriya
LI,LIE,Liechtenstein
LT,LTU,Lithuania
LU,LUX,Luxembourg
MO,MAC,Macau
MK,MKD,Macedonia, Former Yugoslav Republic
MG,MDG,Madagascar
MW,MWI,Malawi
MY,MYS,Malaysia
MV,MDV,Maldives
ML,MLI,Mali
MT,MLT,Malta
MH,MHL,Marshall Islands
MQ,MTQ,Martinique
MR,MRT,Mauritania
MU,MUS,Mauritius
YT,MYT,Mayotte
MX,MEX,Mexico
FM,FSM,Micronesia, Federated States of
MD,MDA,Moldova
MC,MCO,Monaco
MN,MNG,Mongolia
MS,MSR,Montserrat
MA,MAR,Morocco
MZ,MOZ,Mozambique
MM,MMR,Myanmar
NA,NAM,Namibia
NR,NRU,Nauru
NP,NPL,Nepal
NL,NLD,Netherlands
AN,ANT,Netherlands Antilles
NC,NCL,New Caledonia
NZ,NZL,New Zealand
NI,NIC,Nicaragua
NE,NER,Niger
NG,NGA,Nigeria
NU,NIU,Niue
NF,NFK,Norfolk Island
MP,MNP,Northern Mariana Islands
NO,NOR,Norway
OM,OMN,Oman
PK,PAK,Pakistan
PW,PLW,Palau
PS,PSE,Palestinian Territory
PA,PAN,Panama
PG,PNG,Papua New Guinea
PY,PRY,Paraguay
PE,PER,Peru
PH,PHL,Philippines
PN,PCN,Pitcairn
PL,POL,Poland
PT,PRT,Portugal
PR,PRI,Puerto Rico
QA,QAT,Qatar
RE,REU,Reunion
RO,ROM,Romania
RU,RUS,Russian Federation
RW,RWA,Rwanda
SH,SHN,Saint Helena
KN,KNA,Saint Kitts And Nevis
LC,LCA,Saint Lucia
PM,SPM,Saint Pierre and Miquelon
VC,VCT,Saint Vincent And The Grenadines
WS,WSM,Samoa
SM,SMR,San Marino
ST,STP,Sao Tome And Principe
SA,SAU,Saudi Arabia
SN,SEN,Senegal
SC,SYC,Seychelles
SL,SLE,Sierra Leone
SG,SGP,Singapore
SK,SVK,Slovakia (Slovak Republic)
SI,SVN,Slovenia
SB,SLB,Solomon Islands
SO,SOM,Somalia
ZA,ZAF,South Africa
GS,SGS,South Georgia & South Sandwich Islands
ES,ESP,Spain
LK,LKA,Sri Lanka
SD,SDN,Sudan
SR,SUR,Suriname
SJ,SJM,Svalbard And Jan Mayen Islands
SZ,SWZ,Swaziland
SE,SWE,Sweden
CH,CHE,Switzerland
SY,SYR,Syrian Arab Republic
TW,TWN,Taiwan
TJ,TJK,Tajikistan
TZ,TZA,Tanzania
TH,THA,Thailand
TL,TLS,Timor-Leste
TG,TGO,Togo
TK,TKL,Tokelau
TO,TON,Tonga
TT,TTO,Trinidad And Tobago
TN,TUN,Tunisia
TR,TUR,Turkey
TM,TKM,Turkmenistan
TC,TCA,Turks And Caicos Islands
TV,TUV,Tuvalu
UG,UGA,Uganda
UA,UKR,Ukraine
AE,ARE,United Arab Emirates
GB,GBR,United Kingdom
US,USA,United States
UM,UMI,United States Minor Outlying Islands
UY,URY,Uruguay
UZ,UZB,Uzbekistan
VU,VUT,Vanuatu
VE,VEN,Venezuela
VN,VNM,Viet Nam
VG,VGB,Virgin Islands (British)
VI,VIR,Virgin Islands (U.S.)
WF,WLF,Wallis And Futuna Islands
EH,ESH,Western Sahara
YE,YEM,Yemen
YU,YUG,Yugoslavia
ZM,ZMB,Zambia
ZW,ZWE,Zimbabwe"
;

$lines explode("\n"$d);
foreach (
$lines as $l)
{
    
preg_match('/^(..),(...),(.*)$/'$l$matches);
    list(
$l,$code2,$code3,$c) = $matches;
    
$COUNTRY[$code2] = $c;
}

?>