\n"; echo "查询结果:" .$api_arr['QueryResult'] ."
\n"; echo "所属省份:" .$api_arr['Province'] ."
\n"; echo "所属城市:" .$api_arr['City'] ."
\n"; echo "区  号:" .$api_arr['AreaCode'] ."
\n"; echo "邮  编:" .$api_arr['PostCode'] ."
\n"; echo "运 营 商:" .$api_arr['Corp'] ."
\n"; echo "类  型:" .$api_arr['Card'] ."
\n"; } function getMobileInfo($Mobile){ $api_url = "http://api.showji.com/locating/?m={MOBILE}&output=text"; $api_Mobile = $Mobile; if(!is_numeric($api_Mobile)) $api_Mobile = ""; if(!$api_Mobile){ echo "1号码输入有误"; die(); }else{ $api_Mobile = str_replace("-","",$api_Mobile); if(strLen($api_Mobile) < 7 || strLen($api_Mobile) > 11){ echo "2不是完整的11位手机号或者正确的手机号前七位"; die(); } $api_url = str_replace("{MOBILE}", $api_Mobile, $api_url); if(!@file_get_contents($api_url)){ echo "3数据获取错误"; die(); }else{ $api_text = @file_get_contents($api_url); if(strLen($api_text) < 10){ echo "4数据返回错误"; die(); }else{ $api_arr = explode("\n", $api_text); foreach($api_arr as $api_tmp){ $api_text = explode(':', trim($api_tmp)); $api_key = $api_text[0]; $api_value = $api_text[1]; $api_arr[$api_key] = $api_value; } return $api_arr; } } } } ?>