我有这段代码可以获取用户的 IP 地址和纬度和经度。但是,如果它找到纬度和经度,我希望将其显示在地图上。
$theirip = $_SERVER['REMOTE_ADDR'];
$fileinfo = file_get_contents("http://api.easyjquery.com/ips/?ip=".$theirip."&full=true");
这会输出一个这样的字符串。
{"IP":"000.000.00.000","continentCode":"Unknown","continentName":"Unknown","countryCode2":"Unknown","COUNTRY":"Unknown","countryCode3":"Unknown" ,"countryName":"Unknown","regionName":"Unknown","cityName":"Unknown","cityLatitude":0,"cityLongitude":0,"countryLatitude":0,"countryLongitude":0," localTimeZone":"未知","localTime":"0"}
我想从中检索 cityLatitude 和 cityLongitude 。我研究了一些并尝试了一些不同的代码。
$lat = $fileinfo -> {"cityLatitude"};
但我不太确定该怎么做。任何帮助,将不胜感激!