您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

通过IP获取地理位置_PHP教程

2024/3/26 20:08:16发布18次查看
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;
}
上面来自开源中国写的真xxx,新闻我都不好意思发了,我们用正则表达式写更简单
来看看
 function get_ip_arr()
{
    $ip=file_get_contents(http://fw.qq.com/ipaddress);
    preg_match_all(/(.*)/,$ip,$arr);
    return $arr;
}
返回来的是个数组,里面可以任意去取地区或者是ip
http://www.bkjia.com/phpjc/478810.htmlwww.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; } 上...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product