I have the following piece of code taken from the PHP manual on the curl_multi_* entries:
$active = null;
do {
$process = curl_multi_exec($curl, $active);
} while ($process === CURLM_CALL_MULTI_PERFORM);
while (($active >= 1) && ($process === CURLM_OK))
{
if (curl_multi_select($curl, 3) != -1)
{
do {
$process = curl_multi_exec($curl, $active);
} while ($process === CURLM_CALL_MULTI_PERFORM);
}
}
Now the thing is I really don't like writing do...while loops and I was wondering what would is the best and shorter way to accomplish the same but without using this kind of loops.
So far I've come up with a slightly longer version but I'm not sure if it does exactly the same or if it performs the same way as the original one:
while (true)
{
$active = 1;
$process = curl_multi_exec($curl, $active);
if ($process === CURLM_OK)
{
while (($active >= 1) && (curl_multi_select($curl, 3) != -1))
{
$process = CURLM_CALL_MULTI_PERFORM;
while ($process === CURLM_CALL_MULTI_PERFORM)
{
$process = curl_multi_exec($curl, $active);
}
}
break;
}
else if ($process === CURLM_CALL_MULTI_PERFORM)
{
continue;
}
break;
}
Thanks in advance.