This article mainly introduces how php obtains IP addresses and regions through Chianz.com. it is a very useful technique for resolving IP addresses and regions, for more information about how to obtain IP addresses and regions through Chianz.com, see the example in this article. Share it with you for your reference. The specific analysis is as follows:
The result obtained by an IP address is not perfect. The reason is that the IP address resolution of ip138 is not very detailed in dealing with foreign addresses, so I re-wrote a code using Chianz.com, the instance code is as follows:
The code is as follows:
<? Php
$ IpAddr = "4.4.44.4 ";
$ IpChinazAddr = "http://tool.chinaz.com/IP? IP = ". $ ipAddr;
$ Contents = file_get_contents ($ ipChinazAddr );
$ Pattern = "/=>. +
/";
$ String = $ contents;
Preg_match_all ($ pattern, $ string, $ addrArray );
$ Num = count ($ addrArray [0]);
$ Pattern = "/(==>>). + (==>> s )/";
For ($ I = 0; $ I <$ num; $ I ++ ){
$ AddrArray [0] [$ I] = preg_replace ($ pattern, "", $ addrArray [0] [$ I]);
}
Echo"
";
print_r($addrArray);
echo "
";
?>
I hope this article will help you with php programming.