我发现CURLOPT_HTTPHEADER发送header头信息,不设置,请求时也会自动生成头部信息,不影响请求数据
2016-08-30
$xml = simplexml_load_string($tmp);
//echo $xml->string[11];
$array = array(
'0'=>'省份',
'1'=>'城市',
'2'=>'经纬度',
'3'=>'天气图片',
'4'=>'时间',
'5'=>'温度'
);
//print_r($xml->string);
foreach ($array as $key => $value) {
echo $value.":".$xml->string[$key]."<br/>";
}
//echo $xml->string[11];
$array = array(
'0'=>'省份',
'1'=>'城市',
'2'=>'经纬度',
'3'=>'天气图片',
'4'=>'时间',
'5'=>'温度'
);
//print_r($xml->string);
foreach ($array as $key => $value) {
echo $value.":".$xml->string[$key]."<br/>";
}
2016-08-30
把获取的结果用simplexml_load_string转换成迭代对象后,可以用下面的方式获取指定数据
$xml = simplexml_load_string($tmp);
echo $xml->string[11];
$xml = simplexml_load_string($tmp);
echo $xml->string[11];
2016-08-30
单色彩虹的答案比较完整,但做到获取结果只需要
$post = 'theCityCode=' . urlencode('杭州') . '&theUserID='; //post数据
$curl = curl_init();
$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';
$post = 'theCityCode=' . urlencode('杭州') . '&theUserID='; //post数据
$curl = curl_init();
$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';
2016-08-10