Ta dùng file countries.php:
<?php
$anp_cd["AD"]=array("Andorra", "Europe", "Andorra la Vella", "Euro");
$anp_cd["AE"]=array("United Arab Emirates", "Middle East", "Abu Dhabi", "UAE Dirham");
$anp_cd["AF"]=array("Afghanistan", "Asia", "Kabul", "Afghani");
$anp_cd["AG"]=array("Antigua and Barbuda", "Central America and the Caribbean", "Saint John's", "East Caribbean Dollar");
$anp_cd["AI"]=array("Anguilla", "Central America and the Caribbean", "The Valley", "East Caribbean Dollar");
$anp_cd["AL"]=array("Albania", "Europe", "Tirana", "Lek");
$anp_cd["AM"]=array("Armenia", "Commonwealth of Independent States", "Yerevan", "Armenian Dram");
$anp_cd["AN"]=array("Netherlands Antilles", "Central America and the Caribbean", "Willemstad", "Netherlands Antillean guilder");
$anp_cd["AO"]=array("Angola", "Africa", "Luanda", "Kwanza");
$anp_cd["AQ"]=array("Antarctica", "Antarctic Region", "--", "");
$anp_cd["AR"]=array("Argentina", "South America", "Buenos Aires", "Argentine Peso");
$anp_cd["AS"]=array("American Samoa", "Oceania", "Pago Pago", "US Dollar");
$anp_cd["AT"]=array("Austria", "Europe", "Vienna", "Euro");
$anp_cd["AU"]=array("Australia", "Oceania", "Canberra", "Australian dollar");
$anp_cd["AW"]=array("Aruba", "Central America and the Caribbean", "Oranjestad", "Aruban Guilder");
$anp_cd["AZ"]=array("Azerbaijan", "Commonwealth of Independent States", "Baku (Baki)", "Azerbaijani Manat");
$anp_cd["BA"]=array("Bosnia and Herzegovina","Bosnia and Herzegovina ,Europe", "Sarajevo","Convertible Marka");
$anp_cd["BB"]=array("Barbados", "Central America and the Caribbean", "Bridgetown", "Barbados Dollar");
$anp_cd["BD"]=array("Bangladesh", "Asia", "Dhaka", "Taka");
$anp_cd["BE"]=array("Belgium", "Europe", "Brussels", "Euro");
$anp_cd["BF"]=array("Burkina Faso", "Africa", "Ouagadougou", "CFA Franc BCEAO");
$anp_cd["BG"]=array("Bulgaria", "Europe", "Sofia", "Lev");
$anp_cd["BH"]=array("Bahrain", "Middle East", "Manama", "Bahraini Dinar");
$anp_cd["BI"]=array("Burundi", "Africa", "Bujumbura", "Burundi Franc");
$anp_cd["BJ"]=array("Benin", "Africa", "Porto-Novo", "CFA Franc BCEAO");
$anp_cd["BM"]=array("Bermuda", "North America", "Hamilton", "Bermudian Dollar");
$anp_cd["BN"]=array("Brunei Darussalam", "Southeast Asia", "Bandar Seri Begawan", "Brunei Dollar");
$anp_cd["BO"]=array("Bolivia", "South America", "La Paz /Sucre", "Boliviano");
$anp_cd["BR"]=array("Brazil", "South America", "Brasilia", "Brazilian Real");
$anp_cd["BS"]=array("The Bahamas", "Central America and the Caribbean", "Nassau", "Bahamian Dollar");
$anp_cd["BT"]=array("Bhutan", "Asia", "Thimphu", "Ngultrum");
$anp_cd["BV"]=array("Bouvet Island", "Antarctic Region", "--", "Norwegian Krone");
$anp_cd["BW"]=array("Botswana", "Africa", "Gaborone", "Pula");
$anp_cd["BY"]=array("Belarus", "Commonwealth of Independent States", "Minsk", "Belarussian Ruble");
$anp_cd["BZ"]=array("Belize", "Central America and the Caribbean", "Belmopan", "Belize Dollar");
$anp_cd["CA"]=array("Canada", "North America", "Ottawa", "Canadian Dollar");
$anp_cd["CC"]=array("Cocos (Keeling) Islands", "Southeast Asia", "West Island", "Australian Dollar");
$anp_cd["CD"]=array("Congo, Democratic Republic of the", "Africa", "Kinshasa","Franc Congolais");
$anp_cd["CF"]=array("Central African Republic", "Africa", "Bangui", "CFA Franc BEAC");
$anp_cd["CG"]=array("Congo, Republic of the","Africa", "Brazzaville","CFA Franc BEAC");
$anp_cd["CH"]=array("Switzerland", "Europe", "Bern", "Swiss Franc");
$anp_cd["CI"]=array("Cote d'Ivoire", "Africa", "Yamoussoukro", "CFA Franc BCEAO");
$anp_cd["CK"]=array("Cook Islands", "Oceania", "Avarua", "New Zealand Dollar");
$anp_cd["CL"]=array("Chile", "South America", "Santiago", "Chilean Peso");
$anp_cd["CM"]=array("Cameroon", "Africa", "Yaounde", "CFA Franc BEAC");
$anp_cd["CN"]=array("China", "Asia", "Beijing", "Yuan Renminbi");
$anp_cd["CO"]=array("Colombia", "South America,Central America and the Caribbean","Bogota","Colombian Peso");
$anp_cd["CR"]=array("Costa Rica", "Central America and the Caribbean", "San Jose", "Costa Rican Colon");
$anp_cd["CU"]=array("Cuba", "Central America and the Caribbean", "Havana", "Cuban Peso");
$anp_cd["CV"]=array("Cape Verde", "World", "Praia", "Cape Verdean Escudo");
$anp_cd["CX"]=array("Christmas Island", "Southeast Asia", "The Settlement", "Australian Dollar");
$anp_cd["CY"]=array("Cyprus", "Middle East", "Nicosia", "Cyprus Pound");
$anp_cd["CZ"]=array("Czech Republic", "Europe", "Prague", "Czech Koruna");
$anp_cd["DE"]=array("Germany", "Europe", "Berlin", "Euro");
$anp_cd["DJ"]=array("Djibouti", "Africa", "Djibouti", "Djibouti Franc");
$anp_cd["DK"]=array("Denmark", "Europe", "Copenhagen", "Danish Krone");
$anp_cd["DM"]=array("Dominica", "Central America and the Caribbean", "Roseau", "East Caribbean Dollar");
$anp_cd["DO"]=array("Dominican Republic", "Central America and the Caribbean", "Santo Domingo", "Dominican Peso");
$anp_cd["DZ"]=array("Algeria", "Africa", "Algiers", "Algerian Dinar");
$anp_cd["EC"]=array("Ecuador", "South America", "Quito", "US dollar");
$anp_cd["EE"]=array("Estonia", "Europe", "Tallinn", "Kroon");
$anp_cd["EG"]=array("Egypt", "Africa", "Cairo", "Egyptian Pound");
$anp_cd["EH"]=array("Western Sahara", "Africa", "--", "Moroccan Dirham");
$anp_cd["ER"]=array("Eritrea", "Africa", "Asmara", "Nakfa");
$anp_cd["ES"]=array("Spain", "Europe", "Madrid", "Euro");
$anp_cd["ET"]=array("Ethiopia", "Africa", "Addis Ababa", "Ethiopian Birr");
$anp_cd["FI"]=array("Finland", "Europe", "Helsinki", "Euro");
$anp_cd["FJ"]=array("Fiji", "Oceania", "Suva", "Fijian Dollar");
$anp_cd["FK"]=array("Falkland Islands (Islas Malvinas)", "South America", "Stanley", "Falkland Islands Pound");
$anp_cd["FM"]=array("Micronesia, Federated States of","Oceania","Palikir","US dollar");
$anp_cd["FO"]=array("Faroe Islands", "Europe", "Torshavn", "Danish Krone");
$anp_cd["FR"]=array("France", "Europe", "Paris", "Euro");
$anp_cd["FX"]=array("France, Metropolitan", "--", "--", "Euro");
$anp_cd["GA"]=array("Gabon", "Africa", "Libreville", "CFA Franc BEAC");
$anp_cd["GD"]=array("Grenada", "Central America and the Caribbean", "Saint George's", "East Caribbean Dollar");
$anp_cd["GE"]=array("Georgia", "Commonwealth of Independent States", "T'bilisi", "Lari");
$anp_cd["GF"]=array("French Guiana", "South America", "Cayenne", "Euro");
$anp_cd["GG"]=array("Guernsey", "Europe", "Saint Peter Port", "Pound Sterling");
$anp_cd["GH"]=array("Ghana", "Africa", "Accra", "Cedi");
$anp_cd["GI"]=array("Gibraltar", "Europe", "Gibraltar", "Gibraltar Pound");
$anp_cd["GL"]=array("Greenland", "Arctic Region", "Nuuk", "Danish Krone");
$anp_cd["GM"]=array("The Gambia", "Africa", "Banjul", "Dalasi");
$anp_cd["GN"]=array("Guinea", "Africa", "Conakry", "Guinean Franc");
$anp_cd["GP"]=array("Guadeloupe", "Central America and the Caribbean", "Basse-Terre", "Euro");
$anp_cd["GQ"]=array("Equatorial Guinea", "Africa", "Malabo", "CFA Franc BEAC");
$anp_cd["GR"]=array("Greece", "Europe", "Athens", "Euro");
$anp_cd["GS"]=array("South Georgia and the South Sandwich Islands", "Antarctic Region", "--", "Pound Sterling");
$anp_cd["GT"]=array("Guatemala", "Central America and the Caribbean", "Guatemala", "Quetzal");
$anp_cd["GU"]=array("Guam", "Oceania", "Hagatna", "US Dollar");
$anp_cd["GW"]=array("Guinea-Bissau", "Africa", "Bissau", "CFA Franc BCEAO");
$anp_cd["GY"]=array("Guyana", "South America", "Georgetown", "Guyana Dollar");
$anp_cd["HK"]=array("Hong Kong (SAR)", "Southeast Asia", "Hong Kong", "Hong Kong Dollar");
$anp_cd["HM"]=array("Heard Island and McDonald Islands", "Antarctic Region", "--", "Australian Dollar");
$anp_cd["HN"]=array("Honduras", "Central America and the Caribbean", "Tegucigalpa", "Lempira");
$anp_cd["HR"]=array("Croatia", "Europe", "Zagreb", "Kuna");
$anp_cd["HT"]=array("Haiti", "Central America and the Caribbean", "Port-au-Prince", "Gourde");
$anp_cd["HU"]=array("Hungary", "Europe", "Budapest", "Forint");
$anp_cd["ID"]=array("Indonesia", "Southeast Asia", "Jakarta", "Rupiah");
$anp_cd["IE"]=array("Ireland", "Europe", "Dublin", "Euro");
$anp_cd["IL"]=array("Israel", "Middle East", "Jerusalem", "New Israeli Sheqel");
$anp_cd["IM"]=array("Man, Isle of","Europe","Douglas","Pound Sterling");
$anp_cd["IN"]=array("India", "Asia", "New Delhi", "Indian Rupee");
$anp_cd["IO"]=array("British Indian Ocean Territory", "World", "--", "US Dollar");
$anp_cd["IQ"]=array("Iraq", "Middle East", "Baghdad", "Iraqi Dinar");
$anp_cd["IR"]=array("Iran", "Middle East", "Tehran", "Iranian Rial");
$anp_cd["IS"]=array("Iceland", "Arctic Region", "Reykjavik", "Iceland Krona");
$anp_cd["IT"]=array("Italy", "Europe", "Rome", "Euro");
$anp_cd["JE"]=array("Jersey", "Europe", "Saint Helier", "Pound Sterling");
$anp_cd["JM"]=array("Jamaica", "Central America and the Caribbean", "Kingston", "Jamaican dollar");
$anp_cd["JO"]=array("Jordan", "Middle East", "Amman", "Jordanian Dinar");
$anp_cd["JP"]=array("Japan", "Asia", "Tokyo", "Yen");
$anp_cd["KE"]=array("Kenya", "Africa", "Nairobi", "Kenyan shilling");
$anp_cd["KG"]=array("Kyrgyzstan", "Commonwealth of Independent States", "Bishkek", "Som");
$anp_cd["KH"]=array("Cambodia", "Southeast Asia", "Phnom Penh", "Riel");
$anp_cd["KI"]=array("Kiribati", "Oceania", "Tarawa", "Australian dollar");
$anp_cd["KM"]=array("Comoros", "Africa", "Moroni", "Comoro Franc");
$anp_cd["KN"]=array("Saint Kitts and Nevis", "Central America and the Caribbean", "Basseterre", "East Caribbean Dollar");
$anp_cd["KP"]=array("Korea, North","Asia","P'yongyang","North Korean Won");
$anp_cd["KR"]=array("Korea, South","Asia","Seoul","Won");
$anp_cd["KW"]=array("Kuwait", "Middle East", "Kuwait", "Kuwaiti Dinar");
$anp_cd["KY"]=array("Cayman Islands", "Central America and the Caribbean", "George Town", "Cayman Islands Dollar");
$anp_cd["KZ"]=array("Kazakhstan", "Commonwealth of Independent States", "Astana", "Tenge");
$anp_cd["LA"]=array("Laos", "Southeast Asia", "Vientiane", "Kip");
$anp_cd["LB"]=array("Lebanon", "Middle East", "Beirut", "Lebanese Pound");
$anp_cd["LC"]=array("Saint Lucia", "Central America and the Caribbean", "Castries", "East Caribbean Dollar");
$anp_cd["LI"]=array("Liechtenstein", "Europe", "Vaduz", "Swiss Franc");
$anp_cd["LK"]=array("Sri Lanka", "Asia", "Colombo", "Sri Lanka Rupee");
$anp_cd["LR"]=array("Liberia", "Africa", "Monrovia", "Liberian Dollar");
$anp_cd["LS"]=array("Lesotho", "Africa", "Maseru", "Loti");
$anp_cd["LT"]=array("Lithuania", "Europe", "Vilnius", "Lithuanian Litas");
$anp_cd["LU"]=array("Luxembourg", "Europe", "Luxembourg", "Euro");
$anp_cd["LV"]=array("Latvia", "Europe", "Riga", "Latvian Lats");
$anp_cd["LY"]=array("Libya", "Africa", "Tripoli", "Libyan Dinar");
$anp_cd["MA"]=array("Morocco", "Africa", "Rabat", "Moroccan Dirham");
$anp_cd["MC"]=array("Monaco", "Europe", "Monaco", "Euro");
$anp_cd["MD"]=array("Moldova", "Commonwealth of Independent States", "Chisinau", "Moldovan Leu");
$anp_cd["MG"]=array("Madagascar", "Africa", "Antananarivo", "Malagasy Franc");
$anp_cd["MH"]=array("Marshall Islands", "Oceania", "Majuro", "US dollar");
$anp_cd["MK"]=array("Macedonia, The Former Yugoslav Republic of","Europe","Skopje","Denar");
$anp_cd["ML"]=array("Mali", "Africa", "Bamako", "CFA Franc BCEAO");
$anp_cd["MM"]=array("Burma", "Southeast Asia", "Rangoon", "kyat");
$anp_cd["MN"]=array("Mongolia", "Asia", "Ulaanbaatar", "Tugrik");
$anp_cd["MO"]=array("Macao", "Southeast Asia", "Macao", "Pataca");
$anp_cd["MP"]=array("Northern Mariana Islands", "Oceania", "Saipan", "US Dollar");
$anp_cd["MQ"]=array("Martinique", "Central America and the Caribbean", "Fort-de-France", "Euro");
$anp_cd["MR"]=array("Mauritania", "Africa", "Nouakchott", "Ouguiya");
$anp_cd["MS"]=array("Montserrat", "Central America and the Caribbean", "Plymouth", "East Caribbean Dollar");
$anp_cd["MT"]=array("Malta", "Europe", "Valletta", "Maltese Lira");
$anp_cd["MU"]=array("Mauritius", "World", "Port Louis", "Mauritius Rupee");
$anp_cd["MV"]=array("Maldives", "Asia", "Male", "Rufiyaa");
$anp_cd["MW"]=array("Malawi", "Africa", "Lilongwe", "Kwacha");
$anp_cd["MX"]=array("Mexico", "North America", "Mexico", "Mexican Peso");
$anp_cd["MY"]=array("Malaysia", "Southeast Asia", "Kuala Lumpur", "Malaysian Ringgit");
$anp_cd["MZ"]=array("Mozambique", "Africa", "Maputo", "Metical");
$anp_cd["NA"]=array("Namibia", "Africa", "Windhoek", "Namibian Dollar");
$anp_cd["NC"]=array("New Caledonia", "Oceania", "Noumea", "CFP Franc");
$anp_cd["NE"]=array("Niger", "Africa", "Niamey", "CFA Franc BCEAO");
$anp_cd["NF"]=array("Norfolk Island", "Oceania", "Kingston", "Australian Dollar");
$anp_cd["NG"]=array("Nigeria", "Africa", "Abuja", "Naira");
$anp_cd["NI"]=array("Nicaragua", "Central America and the Caribbean", "Managua", "Cordoba Oro");
$anp_cd["NL"]=array("Netherlands", "Europe", "Amsterdam", "Euro");
$anp_cd["NO"]=array("Norway", "Europe", "Oslo", "Norwegian Krone");
$anp_cd["NP"]=array("Nepal", "Asia", "Kathmandu", "Nepalese Rupee");
$anp_cd["NR"]=array("Nauru", "Oceania", "--", "Australian Dollar");
$anp_cd["NU"]=array("Niue", "Oceania", "Alofi", "New Zealand Dollar");
$anp_cd["NZ"]=array("New Zealand", "Oceania", "Wellington", "New Zealand Dollar");
$anp_cd["OM"]=array("Oman", "Middle East", "Muscat", "Rial Omani");
$anp_cd["PA"]=array("Panama", "Central America and the Caribbean", "Panama", "balboa");
$anp_cd["PE"]=array("Peru", "South America", "Lima", "Nuevo Sol");
$anp_cd["PF"]=array("French Polynesia", "Oceania", "Papeete", "CFP Franc");
$anp_cd["PG"]=array("Papua New Guinea", "Oceania", "Port Moresby", "Kina");
$anp_cd["PH"]=array("Philippines", "Southeast Asia", "Manila", "Philippine Peso");
$anp_cd["PK"]=array("Pakistan", "Asia", "Islamabad", "Pakistan Rupee");
$anp_cd["PL"]=array("Poland", "Europe", "Warsaw", "Zloty");
$anp_cd["PM"]=array("Saint Pierre and Miquelon", "North America", "Saint-Pierre", "Euro");
$anp_cd["PN"]=array("Pitcairn Islands", "Oceania", "Adamstown", "New Zealand Dollar");
$anp_cd["PR"]=array("Puerto Rico", "Central America and the Caribbean", "San Juan", "US dollar");
$anp_cd["PS"]=array("Palestinian Territory, Occupied","--","","");
$anp_cd["PT"]=array("Portugal", "Europe", "Lisbon", "Euro");
$anp_cd["PW"]=array("Palau", "Oceania", "Koror", "US dollar");
$anp_cd["PY"]=array("Paraguay", "South America", "Asuncion", "Guarani");
$anp_cd["QA"]=array("Qatar", "Middle East", "Doha", "Qatari Rial");
$anp_cd["RE"]=array("Réunion", "World", "Saint-Denis", "Euro");
$anp_cd["RO"]=array("Romania", "Europe", "Bucharest", "Leu");
$anp_cd["RU"]=array("Russia", "Asia", "Moscow", "Russian Ruble");
$anp_cd["RW"]=array("Rwanda", "Africa", "Kigali", "Rwanda Franc");
$anp_cd["SA"]=array("Saudi Arabia", "Middle East", "Riyadh", "Saudi Riyal");
$anp_cd["SB"]=array("Solomon Islands", "Oceania", "Honiara", "Solomon Islands Dollar");
$anp_cd["SC"]=array("Seychelles", "Africa", "Victoria", "Seychelles Rupee");
$anp_cd["SD"]=array("Sudan", "Africa", "Khartoum", "Sudanese Dinar");
$anp_cd["SE"]=array("Sweden", "Europe", "Stockholm", "Swedish Krona");
$anp_cd["SG"]=array("Singapore", "Southeast Asia", "Singapore", "Singapore Dollar");
$anp_cd["SH"]=array("Saint Helena", "Africa", "Jamestown", "Saint Helenian Pound");
$anp_cd["SI"]=array("Slovenia", "Europe", "Ljubljana", "Tolar");
$anp_cd["SJ"]=array("Svalbard", "Arctic Region", "Longyearbyen", "Norwegian Krone");
$anp_cd["SK"]=array("Slovakia", "Europe", "Bratislava", "Slovak Koruna");
$anp_cd["SL"]=array("Sierra Leone", "Africa", "Freetown", "Leone");
$anp_cd["SM"]=array("San Marino", "Europe", "San Marino", "Euro");
$anp_cd["SN"]=array("Senegal", "Africa", "Dakar", "CFA Franc BCEAO");
$anp_cd["SO"]=array("Somalia", "Africa", "Mogadishu", "Somali Shilling");
$anp_cd["SR"]=array("Suriname", "South America", "Paramaribo", "Suriname Guilder");
$anp_cd["ST"]=array("São Tom?and Príncipe", "Africa", "Sao Tome", "Dobra");
$anp_cd["SV"]=array("El Salvador", "Central America and the Caribbean", "San Salvador", "El Salvador Colon");
$anp_cd["SY"]=array("Syria", "Middle East", "Damascus", "Syrian Pound");
$anp_cd["SZ"]=array("Swaziland", "Africa", "Mbabane", "Lilangeni");
$anp_cd["TC"]=array("Turks and Caicos Islands", "Central America and the Caribbean", "Cockburn Town", "US Dollar");
$anp_cd["TD"]=array("Chad", "Africa", "N'Djamena", "CFA Franc BEAC");
$anp_cd["TF"]=array("French Southern and Antarctic Lands", "Antarctic Region", "--", "Euro");
$anp_cd["TG"]=array("Togo", "Africa", "Lome", "CFA Franc BCEAO");
$anp_cd["TH"]=array("Thailand", "Southeast Asia", "Bangkok", "Baht");
$anp_cd["TJ"]=array("Tajikistan", "Commonwealth of Independent States", "Dushanbe", "Somoni");
$anp_cd["TK"]=array("Tokelau", "Oceania", "--", "New Zealand Dollar");
$anp_cd["TM"]=array("Turkmenistan", "Commonwealth of Independent States", "Ashgabat", "Manat");
$anp_cd["TN"]=array("Tunisia", "Africa", "Tunis", "Tunisian Dinar");
$anp_cd["TO"]=array("Tonga", "Oceania", "Nuku'alofa", "Pa'anga");
$anp_cd["TP"]=array("East Timor", "", "--", "Timor Escudo");
$anp_cd["TR"]=array("Turkey", "Middle East", "Ankara", "Turkish Lira");
$anp_cd["TT"]=array("Trinidad and Tobago", "Central America and the Caribbean", "Port-of-Spain", "Trinidad and Tobago Dollar");
$anp_cd["TV"]=array("Tuvalu", "Oceania", "Funafuti", "Australian Dollar");
$anp_cd["TW"]=array("Taiwan", "Southeast Asia", "Taipei", "New Taiwan Dollar");
$anp_cd["TZ"]=array("Tanzania", "Africa", "Dar es Salaam", "Tanzanian Shilling");
$anp_cd["UA"]=array("Ukraine", "Commonwealth of Independent States", "Kiev", "Hryvnia");
$anp_cd["UG"]=array("Uganda", "Africa", "Kampala", "Uganda Shilling");
$anp_cd["UK"]=array("United Kingdom", "Europe", "London", "Pound Sterling");
$anp_cd["UM"]=array("United States Minor Outlying Islands", "", "--", "US Dollar");
$anp_cd["US"]=array("United States","North America","Washington, DC","US Dollar");
$anp_cd["UY"]=array("Uruguay", "South America", "Montevideo", "Peso Uruguayo");
$anp_cd["UZ"]=array("Uzbekistan", "Commonwealth of Independent States", "Tashkent", "Uzbekistan Sum");
$anp_cd["VA"]=array("Holy See (Vatican City)", "Europe", "Vatican City", "Euro");
$anp_cd["VC"]=array("Saint Vincent and the Grenadines", "Central America and the Caribbean", "Kingstown", "East Caribbean Dollar");
$anp_cd["VE"]=array("Venezuela","South America, Central America and the Caribbean","Caracas","Bolivar");
$anp_cd["VG"]=array("British Virgin Islands", "Central America and the Caribbean", "Road Town", "US dollar");
$anp_cd["VI"]=array("Virgin Islands", "Central America and the Caribbean", "Charlotte Amalie", "US Dollar");
$anp_cd["VN"]=array("Vietnam", "Southeast Asia", "Hanoi", "Dong");
$anp_cd["VU"]=array("Vanuatu", "Oceania", "Port-Vila", "Vatu");
$anp_cd["WF"]=array("Wallis and Futuna", "Oceania", "Mata-Utu", "CFP Franc");
$anp_cd["WS"]=array("Samoa", "Oceania", "Apia", "Tala");
$anp_cd["YE"]=array("Yemen", "Middle East", "Sanaa", "Yemeni Rial");
$anp_cd["YT"]=array("Mayotte", "Africa", "Mamoutzou", "Euro");
$anp_cd["YU"]=array("Yugoslavia", "Europe", "Belgrade", "Yugoslavian Dinar");
$anp_cd["ZA"]=array("South Africa", "Africa", "Pretoria", "Rand");
$anp_cd["ZM"]=array("Zambia", "Africa", "Lusaka", "Kwacha");
$anp_cd["ZW"]=array("Zimbabwe", "Africa", "Harare", "Zimbabwe Dollar");
$anp_cd["PX"]=array("European Union", "none", "Europe", "Euro");
?>
Và: ip1.php
<?
include("countries.php");
function Dot2LongIP ($IPaddr)
{
if ($IPaddr == "") {
return 0;
} else {
$ips = split ("\.", "$IPaddr");
return ($ips[3] + $ips[2] * 256 + $ips[1] * 65536 + $ips[0]
*16777216); }
}
function main()
{
print <<<HTML
<form method=post action=ip1.php?hth=h>
<input name= "IPaddr" value=127.0.0.1 type=text>
<input type=submit value=submit>
</form>
HTML;
}
switch($hth)
{
case "h":
$ipnum= Dot2LongIP ($IPaddr);
$text=file("data.txt");
$ip=false;
for($i=0;$i<count($text);$i++)
{
$t=explode(",",$text[$i]);
$t1=$t[0];
$t2=$t[1];
$t3=$t[4];
$t4=$t[2];
$t1=split("\"",$t1);
$t2=split("\"",$t2);
$t3=split("\"",$t3);
$t4=split("\"",$t4);
$t1=$t1[1];
$t2=$t2[1];
$t3=$t3[1];
$t4=$t4[1];
if($ipnum>=$t1 & $ipnum<=$t2)
{
echo "Country:".$t3;
echo ":
<img width=40 height=30 src=flags/".strtolower($t4).".gif>";
$dl=$anp_cd[$t4];
echo "
Region:".$dl[1];
echo "
Country Capital:".$dl[2];
echo "
Currency:".$dl[3];
$ip=true;
break;
}
}
echo ($ip==false)?"No Country":"";
break;
default:
main();
break;
}
?>