Luckily for developers there is an unambiguous, internationally recognized standard for telephone numbers anywhere in the World called E.164.
The countries library contains a bunch of geographical information which includes international dialing codes.
When a carrier runs out of one set of numbers – like, sadly, premium-rate – they simply introduce a new prefix.
Some changes have enormous implications; in the United Kingdom some years ago, for example, the entire regional numbering system underwent a drastic change, with virtually every area code getting an additional “1” inserted.
We can look up the countries which use a particular dialing code: /** * Gets the dialing codes for a given country * * @param string country The two-character country code * @return array An array of strings representing the dialing codes */ get Codes : function(country) You’ll find these functions packaged up as a module, along with unit tests, in the repository that accompanies the article.
Even international dialing codes, however, aren’t as straightforward as you may think.