Get country code

I can get the country code in ISO form with TelephonyManager::getNetworkCountryIso(), as it returns the USA to the USA, etc., but how can I get the countryโ€™s numerical phone code?

I cannot find any functions providing me with the data I am looking for since I need a function that (for example) returns 01for the USA / Canada, 92for Pakistan and so on.

+3
source share
2 answers

Since they are a short list with a clear alpha-code mapping, maybe you just saved the mapping?

, , , ISO 586, "92", . , .

+2

JSON ISO2 http://country.io/phone.json. PHP, :

$codes = json_decode(file_get_contents("http://country.io/phone.json"), true);
echo $codes['US'];
// => 1
echo $codes['PK'];
// => 92

. http://country.io/data/.

0

Source: https://habr.com/ru/post/1758731/


All Articles