kapec gan ne Posted June 25, 2012 Report Share Posted June 25, 2012 (edited) $arr masiva glabajs peimeram 3000 linku vajadzetu partaisit funkciju ta, lai vertu vala tos 3000 linkus pa 10, nevis uzreiz visus :) function func1($arr){ $hArr = array(); $results = array(); foreach($arr as $val){ $h = curl_init(); curl_setopt($h,CURLOPT_URL,$val); curl_setopt($h,CURLOPT_HEADER,0); curl_setopt($h,CURLOPT_RETURNTRANSFER,1); array_push($hArr,$h); } $mh = curl_multi_init(); foreach($hArr as $k => $h) curl_multi_add_handle($mh,$h); $running = null; do{ curl_multi_exec($mh,$running); }while($running > 0); foreach($hArr as $k => $h){ $res = curl_multi_getcontent($h); //.. } foreach($hArr as $k => $h){ curl_multi_remove_handle($mh,$h); } curl_multi_close($mh); return $results; } EDIT: kaut ka apmeram sadi.. neesmu vel parbaudijis function func1($arr){ $hArr = array(); $results = array(); $count=0; for ($i = 0; $i < count($arr); $i++) { $h = curl_init(); curl_setopt($h,CURLOPT_URL,$arr[$i]); curl_setopt($h,CURLOPT_HEADER,0); curl_setopt($h,CURLOPT_RETURNTRANSFER,1); array_push($hArr,$h); if($count>9 || $i==count($arr)-1){ $mh = curl_multi_init(); foreach($hArr as $k => $h) curl_multi_add_handle($mh,$h); $running = null; do{ curl_multi_exec($mh,$running); }while($running > 0); foreach($hArr as $k => $h){ $res = curl_multi_getcontent($h); //.. } foreach($hArr as $k => $h){ curl_multi_remove_handle($mh,$h); } curl_multi_close($mh); $count = 0; } $count++; } return $results; } Edited June 25, 2012 by kapec gan ne Quote Link to comment Share on other sites More sharing options...
daGrevis Posted June 25, 2012 Report Share Posted June 25, 2012 Pārbaudi. :D Quote Link to comment Share on other sites More sharing options...
kapec gan ne Posted June 25, 2012 Author Report Share Posted June 25, 2012 function func1($arr){ $hArr = array(); $results = array(); $count=0; for ($i = 0; $i < count($arr); $i++) { $h = curl_init(); curl_setopt($h,CURLOPT_URL,$arr[$i]); curl_setopt($h,CURLOPT_HEADER,0); curl_setopt($h,CURLOPT_RETURNTRANSFER,1); array_push($hArr,$h); if($count>9 || $i==count($arr)-1){ $mh = curl_multi_init(); print_r($hArr); foreach($hArr as $k => $h){ curl_multi_add_handle($mh,$h); } $running = null; do{ curl_multi_exec($mh,$running); }while($running > 0); //..... foreach($hArr as $k => $h){ curl_multi_remove_handle($mh,$h); } curl_multi_close($mh); $hArr = array(); $count = 0; } $count++; } return $results; } strada ciesami :P Quote Link to comment Share on other sites More sharing options...
daGrevis Posted June 25, 2012 Report Share Posted June 25, 2012 Nu tad ņem par labu. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.