Return to Snippet

Revision: 33061
at October 5, 2010 18:22 by resting


Updated Code
//To use:
$content['nationality'] = array('#type' => 'select',
                                                      '#title' => 'Nationality',
                                                      '#options' => get_nationality_option());

//source: http://en.wikipedia.org/wiki/Lists_of_people_by_nationality

function get_nationality_option() {
  $nationalities = "
  Afghans
  Afrikaners
  Albanians
  Algerians
  Americans
  Andorrans
  Angolans
  Argentines
  Armenians
  Aromanians
  Arubans
  Australians
  Indigenous Australians
  Austrians
  Azeris
  Bahamians
  Bahrainis
  Balochi
  Bangladeshis
  Barbadians
  Belarusians
  Belgians
  Belizeans
  Boers
  Bosnians
  Brazilians
  Bretons
  British
  British Virgin Islanders
  Bulgarians
  Burkinabès
  Burundians
  Cambodians
  Cameroonians
  Canadians
  Catalans
  Cape Verdeans
  Chadians
  Chileans
  Chinese
  Colombians
  Comorians
  Congolese
  Croatians
  Cubans
  Cypriots
  Turkish Cypriots
  Czechs
  Danes
  Dominicans (Republic)
  Dominicans (Commonwealth)
  Dutch
  East Timorese
  Ecuadorians
  Egyptians
  Emiratis
  English
  Eritreans
  Estonians
  Ethiopians
  Finns
  Finnish Swedish
  Fijians
  Filipinos
  French citizens
  Georgians
  Germans
  Baltic Germans
  Ghanaians
  Gibraltar
  Greeks
  Grenadians
  Guatemalans
  Guianese (French)
  Guineans
  Guinea-Bissau nationals
  Guyanese
  Haitians
  Hondurans
  Hong Kongers
  Hungarians
  Icelanders
  Indians
  Indonesians
  Iranians (Persians)
  Iraqis
  Irish
  Israelis
  Italians
  Ivoirians
  Jamaicans
  Japanese
  Jordanians
  Kazakhs
  Kenyans
  Koreans
  Kosovo Albanians
  Kuwaitis
  Lao
  Latvians
  Lebanese
  Liberians
  Libyans
  Liechtensteiners
  Lithuanians
  Luxembourgers
  Macedonians
  Malawians
  Malaysians
  Maldivians
  Malians
  Maltese
  Manx
  Mauritians
  Mexicans
  Moldovans
  Moroccans
  Mongolians
  Montenegrins
  Namibians
  Nepalese
  New Zealanders (Kiwi)
  Nicaraguans
  Nigeriens
  Nigerians
  Norwegians
  Pakistanis
  Palauans
  Palestinians
  Panamanians
  Papua New Guineans
  Paraguayans
  Peruvians
  Poles
  Portuguese
  Puerto Ricans
  Quebecers
  Réunionnais
  Romanians
  Russians
  Baltic Russians
  Rwandans
  Salvadorans
  São Tomé and Príncipe
  Saudis
  Scots
  Senegalese
  Serbs
  Sicilians
  Sierra Leoneans
  Singaporeans
  Slovaks
  Slovenes
  Somalis
  South Africans
  Spanish
  Sri Lankans
  Sudanese
  Swedes
  Swiss
  Syrians
  Taiwanese
  Tanzanians
  Thais
  Tibetans
  Tobagonians
  Trinidadians
  Turks
  Tuvaluans
  Ugandans
  Ukrainians
  Uruguayans
  Venezuelans
  Vietnamese
  Welsh
  Yemenis
  Zambians
  Zimbabweans";

  $pattern = '/\\n/';
  $nationalities_arr = preg_split($pattern, $nationalities);
  
  //Now format the array
  foreach ($nationalities_arr as $nationality) {
    $new_arr[trim($nationality)] = trim($nationality);
  }
  unset($nationalities_arr);
  return $new_arr;
}

Revision: 33060
at October 5, 2010 18:11 by resting


Initial Code
function get_nationality_option() {
  $nationalities = "
  Afghans
  Afrikaners
  Albanians
  Algerians
  Americans
  Andorrans
  Angolans
  Argentines
  Armenians
  Aromanians
  Arubans
  Australians
  Indigenous Australians
  Austrians
  Azeris
  Bahamians
  Bahrainis
  Balochi
  Bangladeshis
  Barbadians
  Belarusians
  Belgians
  Belizeans
  Boers
  Bosnians
  Brazilians
  Bretons
  British
  British Virgin Islanders
  Bulgarians
  Burkinabès
  Burundians
  Cambodians
  Cameroonians
  Canadians
  Catalans
  Cape Verdeans
  Chadians
  Chileans
  Chinese
  Colombians
  Comorians
  Congolese
  Croatians
  Cubans
  Cypriots
  Turkish Cypriots
  Czechs
  Danes
  Dominicans (Republic)
  Dominicans (Commonwealth)
  Dutch
  East Timorese
  Ecuadorians
  Egyptians
  Emiratis
  English
  Eritreans
  Estonians
  Ethiopians
  Finns
  Finnish Swedish
  Fijians
  Filipinos
  French citizens
  Georgians
  Germans
  Baltic Germans
  Ghanaians
  Gibraltar
  Greeks
  Grenadians
  Guatemalans
  Guianese (French)
  Guineans
  Guinea-Bissau nationals
  Guyanese
  Haitians
  Hondurans
  Hong Kongers
  Hungarians
  Icelanders
  Indians
  Indonesians
  Iranians (Persians)
  Iraqis
  Irish
  Israelis
  Italians
  Ivoirians
  Jamaicans
  Japanese
  Jordanians
  Kazakhs
  Kenyans
  Koreans
  Kosovo Albanians
  Kuwaitis
  Lao
  Latvians
  Lebanese
  Liberians
  Libyans
  Liechtensteiners
  Lithuanians
  Luxembourgers
  Macedonians
  Malawians
  Malaysians
  Maldivians
  Malians
  Maltese
  Manx
  Mauritians
  Mexicans
  Moldovans
  Moroccans
  Mongolians
  Montenegrins
  Namibians
  Nepalese
  New Zealanders (Kiwi)
  Nicaraguans
  Nigeriens
  Nigerians
  Norwegians
  Pakistanis
  Palauans
  Palestinians
  Panamanians
  Papua New Guineans
  Paraguayans
  Peruvians
  Poles
  Portuguese
  Puerto Ricans
  Quebecers
  Réunionnais
  Romanians
  Russians
  Baltic Russians
  Rwandans
  Salvadorans
  São Tomé and Príncipe
  Saudis
  Scots
  Senegalese
  Serbs
  Sicilians
  Sierra Leoneans
  Singaporeans
  Slovaks
  Slovenes
  Somalis
  South Africans
  Spanish
  Sri Lankans
  Sudanese
  Swedes
  Swiss
  Syrians
  Taiwanese
  Tanzanians
  Thais
  Tibetans
  Tobagonians
  Trinidadians
  Turks
  Tuvaluans
  Ugandans
  Ukrainians
  Uruguayans
  Venezuelans
  Vietnamese
  Welsh
  Yemenis
  Zambians
  Zimbabweans";

  $pattern = '/\\n/';
  $nationalities_arr = preg_split($pattern, $nationalities);
  
  //Now format the array
  foreach ($nationalities_arr as $nationality) {
    $new_arr[trim($nationality)] = trim($nationality);
  }
  unset($nationalities_arr);
  return $new_arr;
}

Initial URL

                                

Initial Description

                                

Initial Title
Drupal Nationality List

Initial Tags
list, drupal

Initial Language
PHP