现在的位置: 首页 > 综合 > 正文

使用腾迅的api接口,php获取ip地址以及所在城市

2013年09月21日 ⁄ 综合 ⁄ 共 296字 ⁄ 字号 评论关闭

http://fw.qq.com/ipaddress返回类似:var IPData = new Array("61.51.71.183","","北京市","");

<?php

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;

}

$ip=get_ip_place();

print_r($ip);

?>

抱歉!评论已关闭.