PHP Country List

PHP Country List

The PHP Country List function allows you to convert country codes to names or names to country codes. Supported are 237 Countrys.

Example Code:

//Require the function
require_once 'countrycodelist.php';


echo '---CREATING A SELECT BOX---<br />';

$countrys = countryConversion('all');

echo "<select name='country'>";
foreach($countrys as $country){
    echo "<option value='".$country['code2']."'>".$country['country']."</option>";
echo "</select>";


echo '---CONVERTING country name TO country code---<br />';

$countryCode2 = countryConversion('Spain', 'code2');
$countryCode3 = countryConversion('Spain', 'code3');

echo "The two digit country code from 'Spain' equals ".$countryCode2."<br />";
echo "The three digit country code from 'Spain' equals ".$countryCode3;


echo '---CONVERTING country code TO country name---<br />';

$countryCode2 = countryConversion('zW', 'country');
$countryCode3 = countryConversion('ZwE', 'country');

echo "The two digit country code 'zW' equals ".$countryCode2."<br />";
echo "The three digit country code 'ZwE' equals ".$countryCode3."<br />";

Supported Countrys so far:

Just in case I’ve forgot one, just let me know and I will add it asap for you.
AF, AL, DZ, AS, AD, AO, AI, AQ, AG, AR, AM, AW, AU, AT, AZ, BS, BH, BD, BB, BY, BE, BZ, BJ, BM, BT, BO, BA, BW, BR, IO, VG, BN, BG, BF, MM, BI, KH, CM, CA, CV, KY, CF, TD, CL, CN, CX, CC, CO, KM, CK, CR, HR, CU, CY, CZ, CD, DK, DJ, DM, DO, EC, EG, SV, GQ, ER, EE, ET, FK, FO, FJ, FI, FR, PF, GA, GM, , GE, DE, GH, GI, GR, GL, GD, GU, GT, GN, GW, GY, HT, VA, HN, HK, HU, IS, IN, ID, IR, IQ, IE, IM, IL, IT, CI, JM, JP, JE, JO, KZ, KE, KI, , KW, KG, LA, LV, LB, LS, LR, LY, LI, LT, LU, MO, MK, MG, MW, MY, MV, ML, MT, MH, MR, MU, YT, MX, FM, MD, MC, MN, ME, MS, MA, MZ, NA, NR, NP, NL, AN, NC, NZ, NI, NE, NG, NU, NFK, KP, MP, NO, OM, PK, PW, PA, PG, PY, PE, PH, PN, PL, PT, PR, QA, CG, RO, RU, RW, BL, SH, KN, LC, MF, PM, VC, WS, SM, ST, SA, SN, RS, SC, SL, SG, SK, SI, SB, SO, ZA, KR, ES, LK, SD, SR, SJ, SZ, SE, CH, SY, TW, TJ, TZ, TH, TL, TG, TK, TO, TT, TN, TR, TM, TC, TV, UG, UA, AE, GB, US, UY, VI, UZ, VU, VE, VN, WF, EH, YE, ZM, ZW


Updates are free to anyone who has purchased this item with any type of license.