Drupal country list


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //To use:
  2.  
  3. $content['country'] = array('#type' => 'select',
  4. '#title' => 'Country',
  5. '#options' => get_country_option());
  6.  
  7. //source: http://www.internetworldstats.com/list2.htm
  8.  
  9. function get_country_option() {
  10. $countries = "Afghanistan
  11. Africa
  12. Albania
  13. Algeria
  14. American Samoa
  15. Andorra
  16. Angola
  17. Anguilla
  18. Antarctica
  19. Antigua & Barbuda
  20. Antilles, Netherlands
  21. Arabia, Saudi
  22. Argentina
  23. Armenia
  24. Aruba
  25. Asia
  26. Australia
  27. Austria
  28. Azerbaijan
  29. Bahamas, The
  30. Bahrain
  31. Bangladesh
  32. Barbados
  33. Belarus
  34. Belgium
  35. Belize
  36. Benin
  37. Bermuda
  38. Bhutan
  39. Bolivia
  40. Bosnia and Herzegovina
  41. Botswana
  42. Bouvet Island
  43. Brazil
  44. British Indian Ocean T.
  45. British Virgin Islands
  46. Brunei Darussalam
  47. Bulgaria
  48. Burkina Faso
  49. Burundi
  50. Cambodia
  51. Cameroon
  52. Canada
  53. Cape Verde
  54. Caribbean, the
  55. Cayman Islands
  56. Central African Republic
  57. Central America
  58. Chad
  59. Chile
  60. China
  61. Christmas Island
  62. Cocos (Keeling) Islands
  63. Colombia
  64. Comoros
  65. Congo
  66. Congo, Dem. Rep. of the
  67. Cook Islands
  68. Costa Rica
  69. Cote D'Ivoire
  70. Croatia
  71. Cuba
  72. Cyprus
  73. Czech Republic
  74. Denmark
  75. Djibouti
  76. Dominica
  77. Dominican Republic
  78. East Timor (Timor-Leste)
  79. Ecuador
  80. Egypt
  81. El Salvador
  82. Equatorial Guinea
  83. Eritrea
  84. Estonia
  85. Ethiopia
  86. Europe
  87. European Union
  88. Falkland Islands (Malvinas)
  89. Faroe Islands
  90. Fiji
  91. Finland
  92. France
  93. French Guiana
  94. French Polynesia
  95. French Southern Terr.
  96. Gabon
  97. Gambia, the
  98. Georgia
  99. Germany
  100. Ghana
  101. Gibraltar
  102. Greece
  103. Greenland
  104. Grenada
  105. Guadeloupe
  106. Guam
  107. Guatemala
  108. Guernsey and Alderney
  109. Guiana, French
  110. Guinea
  111. Guinea-Bissau
  112. Guinea, Equatorial
  113. Guyana
  114. Haiti
  115. Heard & McDonald Is.(AU)
  116. Holy See (Vatican)
  117. Honduras
  118. Hong Kong, (China)
  119. Hungary
  120. Iceland
  121. India
  122. Indonesia
  123. Iran, Islamic Republic of
  124. Iraq
  125. Ireland
  126. Israel
  127. Italy
  128. Ivory Coast (Cote d'Ivoire)
  129. Jamaica
  130. Japan
  131. Jersey
  132. Jordan
  133. Kazakhstan
  134. Kenya
  135. Kiribati
  136. Korea Dem. People's Rep.
  137. Korea, (South) Republic of
  138. Kosovo
  139. Kuwait
  140. Kyrgyzstan
  141. Lao People's Democ. Rep.
  142. Latvia
  143. Lebanon
  144. Lesotho
  145. Liberia
  146. Libyan Arab Jamahiriya
  147. Liechtenstein
  148. Lithuania
  149. Luxembourg
  150. Macao, (China)
  151. Macedonia, TFYR
  152. Madagascar
  153. Malawi
  154. Malaysia
  155. Maldives
  156. Mali
  157. Malta
  158. Man, Isle of
  159. Marshall Islands
  160. Martinique (FR)
  161. Mauritania
  162. Mauritius
  163. Mayotte (FR)
  164. Mexico
  165. Micronesia, Fed. States of
  166. Middle East
  167. Moldova, Republic of
  168. Monaco
  169. Mongolia
  170. Montenegro
  171. Montserrat
  172. Morocco
  173. Mozambique
  174. Myanmar (ex-Burma)
  175. Namibia
  176. Nauru
  177. Nepal
  178. Netherlands
  179. Netherlands Antilles
  180. New Caledonia
  181. New Zealand
  182. Nicaragua
  183. Niger
  184. Nigeria
  185. Niue
  186. Norfolk Island
  187. North America
  188. Northern Mariana Islands
  189. Norway
  190. Oceania
  191. Oman
  192. Pakistan
  193. Palau
  194. Palestinian Territory
  195. Panama
  196. Papua New Guinea
  197. Paraguay
  198. Peru
  199. Philippines
  200. Pitcairn Island
  201. Poland
  202. Portugal
  203. Puerto Rico
  204. Qatar
  205. Reunion (FR)
  206. Romania
  207. Russia (Russian Fed.)
  208. Rwanda
  209. Sahara, Western
  210. Saint Barthelemy (FR)
  211. Saint Helena (UK)
  212. Saint Kitts and Nevis
  213. Saint Lucia
  214. Saint Martin (FR)
  215. S Pierre & Miquelon (FR)
  216. S Vincent & Grenadines
  217. Samoa
  218. San Marino
  219. Sao Tome and Principe
  220. Saudi Arabia
  221. Senegal
  222. Serbia
  223. Seychelles
  224. Sierra Leone
  225. Singapore
  226. Slovakia
  227. Slovenia
  228. Solomon Islands
  229. Somalia
  230. South Africa
  231. South America
  232. S.George & S.Sandwich
  233. Spain
  234. Sri Lanka (ex-Ceilan)
  235. Sudan
  236. Suriname
  237. Svalbard & Jan Mayen Is.
  238. Swaziland
  239. Sweden
  240. Switzerland
  241. Syrian Arab Republic
  242. Taiwan
  243. Tajikistan
  244. Tanzania, United Rep. of
  245. Thailand
  246. Timor-Leste (East Timor)
  247. Togo
  248. Tokelau
  249. Tonga
  250. Trinidad & Tobago
  251. Tunisia
  252. Turkey
  253. Turkmenistan
  254. Turks and Caicos Islands
  255. Tuvalu
  256. Uganda
  257. Ukraine
  258. United Arab Emirates
  259. United Kingdom
  260. United States
  261. US Minor Outlying Isl.
  262. Uruguay
  263. Uzbekistan
  264. Vanuatu
  265. Vatican (Holy See)
  266. Venezuela
  267. Viet Nam
  268. Virgin Islands, British
  269. Virgin Islands, U.S.
  270. Wallis and Futuna
  271. Western Sahara
  272. Yemen
  273. Zambia
  274. Zimbabwe";
  275. $pattern = '/\\n/';
  276. $countries_arr = preg_split($pattern, $countries);
  277.  
  278. //Now format the array
  279. foreach ($countries_arr as $country) {
  280. $new_arr[trim($country)] = trim($country);
  281. }
  282. unset($countries_arr);
  283. return $new_arr;
  284. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.