0
while($dataR = mysql_fetch_array($data)){
$postcode = str_replace(" ", "+", $dataR['Postcode']);
echo $postcode."<br />";
$oPostcode = $dataR['Postcode'];
// Retrieve the DOM from a given URL
$url = 'http://www.1.com';
$fields = array(
'txtPostCode'=>urlencode($oPostcode)
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
//execute post
$result = curl_exec($ch);
curl_close($ch);
unset($ch);
//close connection
$html = str_get_html($result);
print_r($html);
}
這就是我的代碼。然而,cURL部分僅在第一次運行 - 我必須做什麼?我試圖瞭解curl_multi_exec
但找不到簡單的答案。cURL在PHP while循環只運行一次
可能重複的:http://stackoverflow.com/questions/4517842/php-curl-loop-post-buffer-not-clearing – seanbreeden 2012-02-29 11:43:19