I am trying to use hostip in order to save to DB user's general area/ location, according to IP address. However I am not sure how to parse the data from the output I am receiving.
<?php $ip = $_SERVER['REMOTE_ADDR']; $data = json_decode(file_get_contents("http://api.hostip.info/get_html.php?ip=$ip")); //<-not sure how $country = $data['Country']; $city = $data['City']; ?> You can see here how I am receiving the data: http://api.hostip.info/get_html.php?ip=00.0.00.00
Another option was to use the first answer here (using ipinfodb): Getting location details from IP in PHP, but it doesn't even display any data, even when I try inserting my IP in the url, let alone parse the results, so I changed to the above.