获取IP所在地

$source=file_get_contents('http://www.ip138.com/ips138.asp?ip='.$ip.'&action=2');

    preg_match_all("/<li>(.*)<\/li>/isU",$source,$result);

    $result = $result[1][0];

    $address = mb_substr( $result, 6, 20, 'gbk');

    $address = mb_convert_encoding($address, "UTF-8", "GBK");

 

你可能感兴趣的:(IP)