我想从国家代码中获取货币代码信息(例如:USD 等)。我尝试了大多数方法,但我无法获得此数据。我从地理定位中获得了国家代码。 我该如何解决这个问题并获取货币代码?
最佳答案
复制此 page 中的对象进入你的代码,像这样
var countryCurrencies = {
"BD": "BDT",
"BE": "EUR",
"BF": "XOF",
...
"UA": "UAH",
"QA": "QAR",
"MZ": "MZN"
}
//get your country code
var countryCode = "ma"; //For example
var currency = countryCurrencies.hasOwnProperty(countryCode.toUpperCase()) ? countryCurrencies[countryCode.toUpperCase()] : "Unkonw";
//The result : curreny = "MAD"
关于javascript - 在 PHP 中从国家代码获取货币信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40804611/