Home  >  Article  >  Backend Development  >  Get geographical location by IP_PHP Tutorial

Get geographical location by IP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:43:52862browse

function get_ip_place()

{
$ip=file_get_contents("http://fw.qq.com/ipaddress");
$ip=str_replace(", ,$ip);
$ip2=explode("(",$ip);
$a=substr($ip2[1],0,-2);
$b=explode(",",$a);
return $b;
}
The above is a real XXX written by Open Source China. I am embarrassed to post the news. It is easier for us to write it using regular expressions
Let’s take a look
function get_ip_arr()
{
$ip=file_get_contents("http://fw.qq.com/ipaddress");
preg_match_all("/"(.*)"/",$ip,$arr);
return $arr;
}
What is returned is an array, in which you can get any region or IP

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478810.htmlTechArticlefunction get_ip_place() { $ip=file_get_contents(http://fw.qq.com/ipaddress); $ ip=str_replace(, ,$ip); $ip2=explode((,$ip); $a=substr($ip2[1],0,-2); $b=explode(,,$a); return $b; } on...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn