Drupal Nationality List


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



Copy this code and paste it in your HTML
  1. //To use:
  2. $content['nationality'] = array('#type' => 'select',
  3. '#title' => 'Nationality',
  4. '#options' => get_nationality_option());
  5.  
  6. //source: http://en.wikipedia.org/wiki/Lists_of_people_by_nationality
  7.  
  8. function get_nationality_option() {
  9. $nationalities = "
  10. Afghans
  11. Afrikaners
  12. Albanians
  13. Algerians
  14. Americans
  15. Andorrans
  16. Angolans
  17. Argentines
  18. Armenians
  19. Aromanians
  20. Arubans
  21. Australians
  22. Indigenous Australians
  23. Austrians
  24. Azeris
  25. Bahamians
  26. Bahrainis
  27. Balochi
  28. Bangladeshis
  29. Barbadians
  30. Belarusians
  31. Belgians
  32. Belizeans
  33. Boers
  34. Bosnians
  35. Brazilians
  36. Bretons
  37. British
  38. British Virgin Islanders
  39. Bulgarians
  40. Burkinabès
  41. Burundians
  42. Cambodians
  43. Cameroonians
  44. Canadians
  45. Catalans
  46. Cape Verdeans
  47. Chadians
  48. Chileans
  49. Chinese
  50. Colombians
  51. Comorians
  52. Congolese
  53. Croatians
  54. Cubans
  55. Cypriots
  56. Turkish Cypriots
  57. Czechs
  58. Danes
  59. Dominicans (Republic)
  60. Dominicans (Commonwealth)
  61. Dutch
  62. East Timorese
  63. Ecuadorians
  64. Egyptians
  65. Emiratis
  66. English
  67. Eritreans
  68. Estonians
  69. Ethiopians
  70. Finns
  71. Finnish Swedish
  72. Fijians
  73. Filipinos
  74. French citizens
  75. Georgians
  76. Germans
  77. Baltic Germans
  78. Ghanaians
  79. Gibraltar
  80. Greeks
  81. Grenadians
  82. Guatemalans
  83. Guianese (French)
  84. Guineans
  85. Guinea-Bissau nationals
  86. Guyanese
  87. Haitians
  88. Hondurans
  89. Hong Kongers
  90. Hungarians
  91. Icelanders
  92. Indians
  93. Indonesians
  94. Iranians (Persians)
  95. Iraqis
  96. Irish
  97. Israelis
  98. Italians
  99. Ivoirians
  100. Jamaicans
  101. Japanese
  102. Jordanians
  103. Kazakhs
  104. Kenyans
  105. Koreans
  106. Kosovo Albanians
  107. Kuwaitis
  108. Lao
  109. Latvians
  110. Lebanese
  111. Liberians
  112. Libyans
  113. Liechtensteiners
  114. Lithuanians
  115. Luxembourgers
  116. Macedonians
  117. Malawians
  118. Malaysians
  119. Maldivians
  120. Malians
  121. Maltese
  122. Manx
  123. Mauritians
  124. Mexicans
  125. Moldovans
  126. Moroccans
  127. Mongolians
  128. Montenegrins
  129. Namibians
  130. Nepalese
  131. New Zealanders (Kiwi)
  132. Nicaraguans
  133. Nigeriens
  134. Nigerians
  135. Norwegians
  136. Pakistanis
  137. Palauans
  138. Palestinians
  139. Panamanians
  140. Papua New Guineans
  141. Paraguayans
  142. Peruvians
  143. Poles
  144. Portuguese
  145. Puerto Ricans
  146. Quebecers
  147. Réunionnais
  148. Romanians
  149. Russians
  150. Baltic Russians
  151. Rwandans
  152. Salvadorans
  153. São Tomé and Príncipe
  154. Saudis
  155. Scots
  156. Senegalese
  157. Serbs
  158. Sicilians
  159. Sierra Leoneans
  160. Singaporeans
  161. Slovaks
  162. Slovenes
  163. Somalis
  164. South Africans
  165. Spanish
  166. Sri Lankans
  167. Sudanese
  168. Swedes
  169. Swiss
  170. Syrians
  171. Taiwanese
  172. Tanzanians
  173. Thais
  174. Tibetans
  175. Tobagonians
  176. Trinidadians
  177. Turks
  178. Tuvaluans
  179. Ugandans
  180. Ukrainians
  181. Uruguayans
  182. Venezuelans
  183. Vietnamese
  184. Welsh
  185. Yemenis
  186. Zambians
  187. Zimbabweans";
  188.  
  189. $pattern = '/\\n/';
  190. $nationalities_arr = preg_split($pattern, $nationalities);
  191.  
  192. //Now format the array
  193. foreach ($nationalities_arr as $nationality) {
  194. $new_arr[trim($nationality)] = trim($nationality);
  195. }
  196. unset($nationalities_arr);
  197. return $new_arr;
  198. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.