After searching for more than four to five hours i got the link which give latitude, longitude and other information such as address including city and country. So here is a small function which will give you latitude and longitude of the given ip address.
function getLatLng($ip){
//get the contents from the site by file_get_contents.
$sXML = @file_get_contents(’http://ipinfodb.com/ip_query.php?ip=’.$ip.’&timezone=false’);
//make the response in a xml object so we can parse it.
$oXML = @new SimpleXMLElement($sXML);
$array = array(
‘Latitude’ => (string) $oXML->Latitude[0],
‘Longitude’ => (string) $oXML->Longitude[0]
);
return $array;
}
