CodeIgniter Forums
country list - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: country list (/showthread.php?tid=25669)



country list - El Forum - 12-20-2009

[eluser]greenba[/eluser]
Hello,

I would like to add country list in array in one place so I can use it over and over again in different controllers.

Where should I store the country array?

Regards,
Green


country list - El Forum - 12-20-2009

[eluser]richthegeek[/eluser]
language, probably


country list - El Forum - 12-20-2009

[eluser]Colin Williams[/eluser]
config/config.php


country list - El Forum - 12-20-2009

[eluser]greenba[/eluser]
Ok,

How to declare it in the config file, like this?

$config['country_list'] = array(
"AF" => "Afghanistan (افغانستان)",
"AX" => "Aland Islands",
"AL" => "Albania (Shqipëria)",
"DZ" => "Algeria (الجزائر)",
"AS" => "American Samoa"
}

How should I call it in the controller?

Thanx


country list - El Forum - 12-20-2009

[eluser]Colin Williams[/eluser]
Code:
$countries = config_item('country_list');

Don't be afraid to look at the User Guide. This is all covered in depth.


country list - El Forum - 12-20-2009

[eluser]greenba[/eluser]
Thanx Colin.