Copy CodeThe code is as follows:
function Get_ip_place ()
{
$ip =file_get_contents ("http://fw.qq.com/ipaddress");
$ip =str_replace (' "', ' ', $IP);
$ip 2=explode ("(", $IP);
$a =substr ($ip 2[1],0,-2);
$b =explode (",", $a);
return $b;
}
The above from the open source China to write the true xxx, the news I was embarrassed to send, we use regular expressions to write more simple
To see
Copy CodeThe code is as follows:
function Get_ip_arr ()
{
$ip =file_get_contents ("http://fw.qq.com/ipaddress");
Preg_match_all ("/\" (. *) \ "/", $ip, $arr);
return $arr;
}
The return is a number of groups, which can be arbitrarily taken to the region or IP
Of course, you can also read the IP address through PHP, the code benefit is to conserve resources.
http://www.bkjia.com/PHPjc/323584.html www.bkjia.com true http://www.bkjia.com/PHPjc/323584.html techarticle Copy the code as follows: function Get_ip_place () {$ip =file_get_contents ("http://fw.qq.com/ipaddress"); $ip =str_replace (' "', '" , $IP); $ip 2=explode ("(", $IP); $a =substr ($ip 2[1],0,-...