$nodes = array($url1, $url2, $url3);
$node_count = count($nodes);
$curl_arr = array();
$master = curl_multi_init();
for ($i = 0; $i < $node_count; $i++) {
$url = $nodes[$i];
$curl_arr[$i] = curl_init($url);
curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, true);
curl_multi_add_handle($master, $curl_arr[$i]);
}
do {
curl_multi_exec($master, $running);
} while ($running > 0);
for ($i = 0; $i < $node_count; $i++) {
$results[] = curl_multi_getcontent($curl_arr[$i]);
}
print_r($results);
//Is this part really parallel ?
for ($i = 0; $i < $node_count; $i++) {
$results[] = curl_multi_getcontent($curl_arr[$i]);
#now i want to perform one task again parallely with all url .
$var = 1; # it will increase till condition is satisfied
#in task lets say i want to to change all url to $url1%20something$var
#parallely with others url also $url2%20something$var , $url3%20something$var
# lets say for $var=6
#when condition after fetching for $res=curl_multi_get_content($url1%20something$var), $res==true is satisfied , it will stop for one url .
//till for others it will continue .
#insort task is loop with parallel . possible ? how ?
}
insort 任务是并行的循环。可能的 ?如何 ?我在代码中解释了我想要的。. 在为每个 url 获取内容后的最后一个 for 循环中,我想再次为所有 url 并行执行一些任务?
那可能吗 ?请问谁能告诉我如何使用 curl ?我尝试了一些,但失败了。