DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Array Of Country List In PHP With Zend Framework

12.22.2007
| 14961 views |
  • submit to reddit
        Array of country list in PHP with Zend Framework, ordered by country name

<?php
header('Content-Type: text/html; charset=utf-8');
require_once 'Zend/Locale.php';

$locale = new Zend_Locale('en_US');

$countries = ($locale->getTranslationList('country', 'en'));
asort($countries, SORT_LOCALE_STRING);

echo "<pre>";
print_r($countries);
echo "</pre>";
    

Comments

Snippets Manager replied on Sun, 2008/03/09 - 11:10pm

This is not exactly correct. The parameter 'country' is not valid. I am not sure if this changed in recent releases but here is the corrected code: <?php header('Content-Type: text/html; charset=utf-8'); require_once 'Zend/Locale.php'; $locale = new Zend_Locale('en_US'); $countries = ($locale->getTranslationList('Territory', 'en', 2)); asort($countries, SORT_LOCALE_STRING); echo "
";
print_r($countries);
echo "
";