Hi,
On the main projectpage it is stated that this module "Typical usage would be converting a country name to its ISO2 (or ISO3) country code". Could you please tell me with code how I can do this using these api's?

Next to this I have the countryname in my own country format, dutch, so sometimes "holland" or "Nederland", or "Netherlands".
Is there some code to say in pseudocode:
1) First alter the countryname to it's english alterego, say something like "holland" or "Nederland" will become "The Netherlands".
2) Then convert the countryname to countrycode. "The Netherlands" becomes "NL".

Thanks a lot in advance for helping me!
Greetings, Martijn

Comments

summit’s picture

I found this piece of code:

<?php
$country_names = location_get_iso3166_list();
print $country_names[location['country']] ?>
?>

may be this is usable the other way around with converting?

mrfelton’s picture

You may want to read the API documentation:
http://www.kirkdesigns.co.uk/docs/drupal-country-codes-api-module/countr...

location_get_iso3166_list() is nothing todo with this module, it is a function provided by the location module.

summit’s picture

Hi,

I did, but couldn;t find a api to use to get from countryname to countrycode.
Please assist.
Thanks a lot in advance!
Greetings, Martijn

mrfelton’s picture

There is currently no function for this, however you could run your own query to do this... something like:

$iso2 = db_result(db_query("select iso2 from {countries_api_countries} where name = '%s'", $countryname));
summit’s picture

Status: Active » Closed (fixed)

Hi, closing this issue, while this needs to work, right? whole issue with also 1) on http://drupal.org/node/427502#comment-1690314

rooby’s picture