$data_struct = array();
$data_struct[]['opts'] = array( CURLOPT_URL => 'http://www.yahoo.com/', CURLOPT_RETURNTRANSFER => true);
$data_struct[]['opts'] = array( CURLOPT_URL => 'http://www.google.com/', CURLOPT_RETURNTRANSFER => true);
$data_struct[]['opts'] = array( CURLOPT_URL => 'http://404.php.net/', CURLOPT_RETURNTRANSFER => true);
//create the multiple cURL handle
$mh = curl_multi_init();
// create and add handles to data structure
foreach ($data_struct as $i => $data){
$data_struct[$i]['handle'] = curl_init();
curl_setopt_array($data_struct[$i]['handle'], $data_struct[$i]['opts']);
curl_multi_add_handle($mh, $data_struct[$i]['handle']);
}
$active = null;
//execute the handles
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && …
Run Code Online (Sandbox Code Playgroud)