Tuesday, December 23, 2014

Moodle - get country list and add additional country



Moodle countries list not stored in database. Its maintained in moodle language files.

Following path to find the countries list : \lang\en\countries.php

To get the countries list like this :

$countries = get_string_manager()->get_list_of_countries(false);

Output:

Array
(
    [AX] => Ă…land Islands
    [AF] => Afghanistan
    [AL] => Albania
    [DZ] => Algeria
    [AS] => American Samoa
    [AD] => Andorra
    .
    .
    .
    .
   [YE] => Yemen
   [ZM] => Zambia
   [ZW] => Zimbabwe
)