PHP - stop all curl_multi requests at a certain point

364 Views Asked by At

I have a php script that uses curl_multi to make multiple requests at the same time.

It accesses several of my sites in search for a defined value.

Now the problem that I have is that the curl requests should stop if it found the value I'm searching for on one of the sites.

Let's say I parse 1000 pages for the word stackoverflow. The script accesses those pages with curl_multi and 10 requests at a time. Let's say the script found the word stackoverflow on the 589th page, it should stop all further requests now.

Is that somehow possible?

1

There are 1 best solutions below

0
On BEST ANSWER

somewhere in your code, your have a loop that processes the individual curl handles. In that loop, you insert the following logic.

if(shouldStop()) {
    break;
}