PHP Country Array

March 29, 2009

Here is an easy to use function to allow you to display a list of countries to your users - this avoids them having to type it out (potentially incorrectly), and is ideal for use in a select field (drop-down box).

As an added bonus, you can also download a collection of flag images, with each image filename renamed to match the corresponding array key. The original images can be found at famfamfam.

Note: There may be a couple of countries in the array that don’t have a corresponding flag image, and vice-versa.

Downloads

Country Flags

Usage:

<?php
country_list(); // returns the entire array
country_list(224); // returns "United Kingdom"
comments powered by Disqus