RE: Get country from Phone number

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2008-02-29 at 05:17 -0500, Andrés Robinet wrote:
> > -----Original Message-----
> > From: Dani Castaños [mailto:danitao.mailists@xxxxxxxxx]
> > Sent: Friday, February 29, 2008 5:03 AM
> > To: PHP LIST
> > Subject:  Get country from Phone number
> > 
> > Hi all!
> > 
> > I'm looking for some piece of code or class which giving a phone number
> > it returns me from wich country is this phone.
> > Do you know where I can find something like this?
> > 
> > Thank you in advanced!
> > 
> > --
> 
> Seems like you'll have a hard time if you want to include all the possibilities:
> http://www.kropla.com/dialcode.htm
> But probably Rob (Cummings) will come up with a "solve-it-all" regex that will
> save your day.

Regex is powerful, but I have my doubts it'll work in this case. If the
phone numbers are in standardized international format then it should be
a bit easier. Then you'll need a mapping of country codes to country.
Finally you'll need to be able to match variables length country codes
to the lookup map. I'm not sure, but it may be possible to determine the
largest possible country code and then use that as a first substring
attempt lookups into the mapping array. Then loop through the mapping
array and find the first country that has a prefix of the country code.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux