dongqiancui9194 2010-08-11 08:20
浏览 59
已采纳

转换国家/地区代

There are several methods on country codes.

I have a list of codes with 3-characters, like on this page:

http://www.fina.org/H2O/index.php?option=com_content&view=category&id=93:asia&Itemid=638&layout=default

Is there a simple way to convert them to 2-characters? Like "PT" from "POR" for Portugal.

Standard for 2-characters - http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

Thanks.

  • 写回答

12条回答 默认 最新

  • dpwjx32578146 2010-08-11 08:27
    关注

    There is going to be no easy way because there is no particular scheme in the names of the country. For example PT from POR for Portugal and this can be different for other countries as well. You might want to create an array to hold two letters for each country.

    Example:

    $countries = array('PT' => 'Portugal', 'UK' => 'United Kingdom');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(11条)

报告相同问题?