Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth
Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

42,690 questions

55,449 answers

573 users

How to use curl_multi_info_read() to get information about the current transfers in PHP

1 Answer

0 votes
$urls = array(
   "http://www.collectivesolver.com/",
   "http://www.buyfrompictures.com/",
   "http://www.php.net/"
);

$cumh = curl_multi_init();

foreach ($urls as $i => $url) 
{
    $con[$i] = curl_init($url);
    curl_setopt($con[$i], CURLOPT_RETURNTRANSFER, 1);
    curl_multi_add_handle($cumh, $con[$i]);
}

$exc = null;
do 
{
    $status = curl_multi_exec($cumh, $exc);
    $info = curl_multi_info_read($cumh);
    if ($info !== false) 
        var_dump($info);
} while ($status === CURLM_CALL_MULTI_PERFORM || $exc);

foreach ($urls as $i => $url) 
{
    $content[$i] = curl_multi_getcontent($con[$i]);
    curl_close($con[$i]);
}

echo "<pre>";
print_r(curl_multi_info_read($cumh));
echo "</pre>";



/*
run: 

array(3) { ["msg"]=> int(1) ["result"]=> int(0) ["handle"]=> resource(5) of type (curl) } 
array(3) { ["msg"]=> int(1) ["result"]=> int(0) ["handle"]=> resource(3) of type (curl) } 
array(3) { ["msg"]=> int(1) ["result"]=> int(0) ["handle"]=> resource(4) of type (curl) } 

*/

 



answered Jun 8, 2016 by avibootz
...