PHP Help Needed

TheMonster786

BANNED
Joined
Dec 14, 2013
Messages
160
Reaction score
38
I need a simple PhP coding Help .

i want to show the Area Code of USA visitor's According to their Location .

For Example , if any visitor comes from "Alaska" , it will show the Area Code of Alaska " 907".

Hope to get solution Soon ...


Thanks in Advance ...
 
you can do that by using geoip_record_by_name php function :) I can't post links yet, but you can check it out by yourself on the official documentation
 
you can do that by using geoip_record_by_name php function :) I can't post links yet, but you can check it out by yourself on the official documentation

i just need to show the Area Code ....

What would be the PHP code for it ?
 
this is through 3rd party service requires some extra load time,
you can replace "city" mentioned below to get your info
Note: you will not be able to get info if this website is down
$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
echo $details->city; // -> "Mountain View"
 
Hey,

it should be something like this:
Code:
 include('geoipcity.inc');
 $gi = geoip_open('GeoLiteCity.dat',GEOIP_STANDARD);
 $surfer_loc = geoip_record_by_addr($gi,$_SERVER["REMOTE_ADDR"]);
 echo $surfer_loc->area_code;
 
Back
Top