如何在使用curl时等待代码执行

时间:2014-09-03 17:28:54

标签: php curl

我有一个代码

for($i=1;;$i++){
    //curl my function... I have set CURLOPT_TIMEOUT=600, this return content of url
    $site= $this->curl_function('http://example.com/'.$i);

    //filtering everything I need
    preg_match_alL('/<a href="(.+?)">(.+?)<\/a>/mis',$site,$match,PREG_SET_ORDER);

    //if url not content then exit
    if(isset($match['0']['2'])) exit;
}

我的问题是如何等待curl,preg_match_all执行然后退出... 当$ i = 1或$ i = 2时,我的代码总是退出。 谢谢!

0 个答案:

没有答案