創(chuàng)新互聯(lián)主要從事成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)薩嘎,10年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792
//查詢ip歸屬地
function ipclient($ip){
$url = "http://api.k780.com:88/?app=ip.get&ip=$ip&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json";
$return = file_get_contents($url);
$arr = json_decode($return,true);
$arrs = explode(",",$arr['result']['area_style_areanm']);
return $arrs[1];
}
$array = array();
$iparray = array('1'=>'220.181.111.85', '2'=>'220.181.111.86', '3'=>'202.104.149.156', '4'=>'42.120.194.11', '5'=>'121.14.24.241');
//轉(zhuǎn)變數(shù)組
foreach($iparray as $val){
$iparrs[] = array('address' => ipclient($val),'ip'=>$val);
}
$area = $re = $persons = array();
foreach ($iparrs as $key=>$val) {
$area[] = $val['address'];
}
$area = array_unique($area); //獲取地區(qū)數(shù)組集合
foreach ($iparrs as $key=>$val) {
foreach ($area as $area_key=>$area_val) {
if ($val['address'] == $area_val) {
$persons[$area_key][] = $val['ip'];
$re[$area_key] = array(
'address' => $area_val,
'persons' => $persons[$area_key],
);
}
}
}
$re = array_values($re);
echo '
';print_r($re);
echo '
';?>
當(dāng)前名稱:ip歸屬地查詢
網(wǎng)址分享:http://weahome.cn/article/ghgehp.html