Skip to content

Instantly share code, notes, and snippets.

@KamranSyed
Last active May 5, 2018 18:30
Show Gist options
  • Select an option

  • Save KamranSyed/e67bb48136aedd36a9f5904822f149de to your computer and use it in GitHub Desktop.

Select an option

Save KamranSyed/e67bb48136aedd36a9f5904822f149de to your computer and use it in GitHub Desktop.
Find Location by IP Address using PHP
<?php
/**
* This is part of a video tutorial
* at https://youtu.be/_HqS12AOwTk
* relevant instructions can be found
* in the description below the video.
*/
$ip = $_SERVER['REMOTE_ADDR'];
$location = file_get_contents('http://ip-api.com/json/'.$ip );
$locData = json_decode($location, true);
echo "<pre>";
print_r($locData);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment