获取手机归属地

http://life.tenpay.com/cgi-bin/mobile/MobileQueryAttribution.cgi?chgmobile=13770737399
<?php
$fileContent = file_get_contents("http://life.tenpay.com/cgi-bin/mobile/MobileQueryAttribution.cgi?chgmobile=18603305207");
//转换为simplexml对象
$xmlResult = simplexml_load_string($fileContent);
//foreach循环遍历
$array = array();
foreach($xmlResult->children() as $key=>$val) {
//输出xml节点名称和值
if($key == "province"){
$array["province"] = "".$val;
}
if($key == "city"){
$array["city"] = "".$val;
}
if($key == "supplier"){
$array["roletype"] = "".$val;
}
}
var_dump($array);
?>

你可能感兴趣的:(获取手机归属地)