を使用してcurl_multi_*
、x リクエストごとにコードを実行したいのですが、実行する方法はありますか?
私が思いついた唯一の方法は、$still_running
からの変数をチェックすることですがcurl_multi_exec
、残念ながら、それは機能しません(一貫性がなく、6、5などを通過せずに7から1にジャンプすることがあります..)
これが私が思いついたコードです($still_running
一貫性がないと言ったように、常に機能するとは限りません):
$still_running = null;
$callbackExecuted = 1;//Counts how many times callback function was executed.
//execute the handles
do
{
//Execute callback every 5 requests
if ($numberOfRequests - $still_running === 5 * $callbackExecuted)
{
callback();
$callbackExecuted++;
}
curl_multi_exec($mh, $still_running);
} while ($still_running > 0);