Reputation: 185
In my app , I am using phone numbers like +17896786788
,+322657579849
.
I would like to retrieve only the country code
i.e, +1
or +322
by passing any phone number, that is I will send phone number and it will return the country code of that number.
Is there any API or anything available to get the country code from the phone number?
How can I find that?
Upvotes: 1
Views: 2262
Reputation: 1468
I dont know about an API for splitting country code from a phone number, But you can use this link to get all countries and their corresponding codes. Its a json file. You first parse all codes to an array from this json and then compare each element wth your phone number by using "range" funtion along with + symbol
Try it. U will get it.
Upvotes: 1