curl multi php

Solutions on MaxInterview for curl multi php by the best coders in the world

showing results for - "curl multi php"
Luc
14 Feb 2019
1$nodes = array('http://www.google.com', 'http://www.microsoft.com', 'http://www.rustyrazorblade.com');
2$node_count = count($nodes);
3
4$curl_arr = array();
5$master = curl_multi_init();
6
7for($i = 0; $i < $node_count; $i++)
8{
9    $url =$nodes[$i];
10    $curl_arr[$i] = curl_init($url);
11    curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, true);
12    curl_multi_add_handle($master, $curl_arr[$i]);
13}
14
15do {
16    curl_multi_exec($master,$running);
17} while($running > 0);
18
19echo "results: ";
20for($i = 0; $i < $node_count; $i++)
21{
22    $results = curl_multi_getcontent  ( $curl_arr[$i]  );
23    echo( $i . "\n" . $results . "\n");
24}
25echo 'done';