我發(fā)現(xiàn)CURLOPT_HTTPHEADER發(fā)送header頭信息,不設(shè)置,請求時也會自動生成頭部信息,不影響請求數(shù)據(jù)
2016-08-30
$xml = simplexml_load_string($tmp);
//echo $xml->string[11];
$array = array(
'0'=>'省份',
'1'=>'城市',
'2'=>'經(jīng)緯度',
'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'=>'經(jīng)緯度',
'3'=>'天氣圖片',
'4'=>'時間',
'5'=>'溫度'
);
//print_r($xml->string);
foreach ($array as $key => $value) {
echo $value.":".$xml->string[$key]."<br/>";
}
2016-08-30
把獲取的結(jié)果用simplexml_load_string轉(zhuǎn)換成迭代對象后,可以用下面的方式獲取指定數(shù)據(jù)
$xml = simplexml_load_string($tmp);
echo $xml->string[11];
$xml = simplexml_load_string($tmp);
echo $xml->string[11];
2016-08-30
單色彩虹的答案比較完整,但做到獲取結(jié)果只需要
$post = 'theCityCode=' . urlencode('杭州') . '&theUserID='; //post數(shù)據(jù)
$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數(shù)據(jù)
$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