PHP, array of countries

So I was looking to get the countries names and end up with this, how would it be useful for you would ask?, well if your are creating a credential based form you could require to add that option.

It comes handy to have it for use at any moment. Remember to first check if the file exists before requiring it like so.

if( file_exists( $path_to_file . 'countries.php' ) 
{
   require_once $path_to_file . 'countries.php';
}

So then save this PHP array of countries in a document with the PHP extension, I named my example countries.php. Don’t forget to add the PHP opening and closing tags.

$countries = array(
    "Afghanistan",
    "Albania",
    "Algeria",
    "Andorra",
    "Angola",
   "Antigua and Barbuda",
    "Argentina",
    "Armenia",
    "Australia",
    "Austria",
    "Azerbaijan",
   "Bahamas",
    "Bahrain",
    "Bangladesh",
   "Barbados",
   "Belarus",
    "Belgium",
    "Belize",
   "Benin",
    "Bhutan",
   "Bolivia",
    "Bosnia and Herzegovina",
   "Botswana",
   "Brazil",
   "Brunei",
   "Bulgaria",
   "Burkina Faso",
   "Burundi",
    "Cambodia",
   "Cameroon",
   "Canada",
   "Cape Verde",
   "Central African Republic",
   "Chad",
   "Chile",
    "China",
    "Colombia",
   "Comoros",
    "Congo (Brazzaville)",
    "Congo",
    "Costa Rica",
   "Cote d'Ivoire",
   "Croatia",
    "Cuba",
   "Cyprus",
   "Czech Republic",
   "Denmark",
    "Djibouti",
   "Dominica",
   "Dominican Republic",
   "East Timor (Timor Timur)",
   "Ecuador",
    "Egypt",
    "El Salvador",
    "Equatorial Guinea",
    "Eritrea",
    "Estonia",
    "Ethiopia",
   "Fiji",
   "Finland",
    "France",
   "Gabon",
    "Gambia, The",
    "Georgia",
    "Germany",
    "Ghana",
    "Greece",
   "Grenada",
    "Guatemala",
    "Guinea",
   "Guinea-Bissau",
    "Guyana",
   "Haiti",
    "Honduras",
   "Hungary",
    "Iceland",
    "India",
    "Indonesia",
    "Iran",
   "Iraq",
   "Ireland",
    "Israel",
   "Italy",
    "Jamaica",
    "Japan",
    "Jordan",
   "Kazakhstan",
   "Kenya",
    "Kiribati",
   "Korea, North",
   "Korea, South",
   "Kuwait",
   "Kyrgyzstan",
   "Laos",
   "Latvia",
   "Lebanon",
    "Lesotho",
    "Liberia",
    "Libya",
    "Liechtenstein",
    "Lithuania",
    "Luxembourg",
   "Macedonia",
    "Madagascar",
   "Malawi",
   "Malaysia",
   "Maldives",
   "Mali",
   "Malta",
    "Marshall Islands",
   "Mauritania",
   "Mauritius",
    "Mexico",
   "Micronesia",
   "Moldova",
    "Monaco",
   "Mongolia",
   "Morocco",
    "Mozambique",
   "Myanmar",
    "Namibia",
    "Nauru",
    "Nepa",
   "Netherlands",
    "New Zealand",
    "Nicaragua",
    "Niger",
    "Nigeria",
    "Norway",
   "Oman",
   "Pakistan",
   "Palau",
    "Panama",
   "Papua New Guinea",
   "Paraguay",
   "Peru",
   "Philippines",
    "Poland",
   "Portugal",
   "Qatar",
    "Romania",
    "Russia",
   "Rwanda",
   "Saint Kitts and Nevis",
    "Saint Lucia",
    "Saint Vincent",
    "Samoa",
    "San Marino",
   "Sao Tome and Principe",
    "Saudi Arabia",
   "Senegal",
    "Serbia and Montenegro",
    "Seychelles",
   "Sierra Leone",
   "Singapore",
    "Slovakia",
   "Slovenia",
   "Solomon Islands",
    "Somalia",
    "South Africa",
   "Spain",
    "Sri Lanka",
    "Sudan",
    "Suriname",
   "Swaziland",
    "Sweden",
   "Switzerland",
    "Syria",
    "Taiwan",
   "Tajikistan",
   "Tanzania",
   "Thailand",
   "Togo",
   "Tonga",
    "Trinidad and Tobago",
    "Tunisia",
    "Turkey",
   "Turkmenistan",
   "Tuvalu",
   "Uganda",
   "Ukraine",
    "United Arab Emirates",
   "United Kingdom",
   "United States",
    "Uruguay",
    "Uzbekistan",
   "Vanuatu",
    "Vatican City",
   "Venezuela",
    "Vietnam",
    "Yemen",
    "Zambia",
   "Zimbabwe"
  );

There you go, that’s all there is to it.. now you have the countries names in an array so you can use it in forms, hope comes handy sometime and help someonebody down the road a Tech User like me..