IP-to-Country converter (php script)
Hi,
I am looking for a PHP script that can take an ip address and return the country where that ip address belongs to.
If you know or have been using such a script, please let me know.
Thanks
Hi,
I am looking for a PHP script that can take an ip address and return the country where that ip address belongs to.
If you know or have been using such a script, please let me know.
Thanks
Greg K posted this at 07:16 — 17th June 2006.
He has: 2,145 posts
Joined: Nov 2003
What about just calling whois {ip address} from PHP and grabbing the country code.
At least on my server, when I do a whois 130.101.206.49, I get the following (I just posted the first section)
OrgName: University of Akron
OrgID: UNIVER-97
Address: Computer Center
Address: 185 Carroll St
City: Akron
StateProv: OH
PostalCode: 44325-3501
Country: US
All the tests I just did came back with this format, so I should be able to just go grab the line that starts with COUNTRY:
If you need help on how to do this, let me know.
-Greg
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.