Ryan
Ryan

Reputation: 433

Parsing certain information from an html page

I am trying to find a way to retrieve a users zip code based on their IP address. I would like to accomplish this without using a massive database. I found this script to get the state by IP, however I need it to grab the zipcode, I tried modifying the parameters of the strip_tags, but no dice.

Here is what I have so far:

$ip =$_SERVER['REMOTE_ADDR'];
$a=file("http://www.geoiptool.com/en/?IP=$ip");
$zip=strip_tags($a[126]);
$zip=str_replace(" ","",$zip);

All help is appreciated! Thanks!

Upvotes: 1

Views: 98

Answers (1)

DaveShaw
DaveShaw

Reputation: 52798

Isn't the Postal Code at index $a[134]?

Upvotes: 2

Related Questions