Hi there,
I have been trying to strip information out of a dynamically generated page and then insert the information into a database, this is only a one time thing. to explain the layout:
I have a list of 700 IP addresses in my database currently but they have no location linked to them, I am using the following code to retrieve the information from hostip.info and insert the returned data into a variable on a loop:
dbconnect();
$tbl_name = 'Votes';
$sql = "SELECT * FROM $tbl_name LIMIT 10"; //THIS LIMIT IS ONLY A TEMPORARY //
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
while($rows=mysql_fetch_array($result)) {
echo $rows['UIP']; //This is the IP stored currently
$file_l = file_get_contents('http://api.hostip.info/get_html.php?ip='.$rows['UIP'].'&position=true');
}
For each IP tested the information returned from hostip.info looks a bit like this:
Country: UNITED KINGDOM (GB)
City: (Unknown city)
Latitude:
Longitude:
IP: 79.170.40.245
just in plain text, I basically want to grab the Lat, Long and City from it and whack it in a database, HOWEVER, the city, lat and long are all different lengths. Is there any way to strip this information with maybe preg_match or something like that, I have tried but Can't figure it out. Any ideas greatly appreciated.