Skip to main content


Showing posts from October, 2010

Finding Geographical location from IP address

How to find the country from IP Address?

After a long search i could find a solution for that.

First function is for fetching contents from an API url
the API Url used here is IP Address

This function will work if your server allows thi stype of fetching from another server

//function to find country and city from IP address
//Developed by Roshan Bhattarai
//verify the IP address

ip2long($ipAddr)== -1 || ip2long($ipAddr) === false ? trigger_error("Invalid IP", E_USER_ERROR) : "";

        $ipDetail=array(); //initialize a blank array
//get the XML result from
        $xml = file_get_contents("".$ipAddr);

    //get the city name inside the node and
//assing the city name to the array
//get the country name ins…

Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to   Read more »
Search This Blog