Yngvarr

Generation

generate functionThu, 13 Apr 2023

curl asynchrone pool

<?php $urls = array( 'http://www.example.com', 'http://www.example.com/foo/bar', 'http://www.example.com/baz/qux', ); $multi = curl_multi_init(); $handles = array(); foreach ($urls as $key => $url) { $handles[$key] = curl_init($url); curl_setopt($handles[$key], CURLOPT_RETURNTRANSFER, true); curl_multi_add_handle($multi, $handles[$key]); } $running = null; do { curl_multi_exec($multi, $running); } while ($running); foreach ($handles as $key => $handle) { $results[$key] = curl_multi_getcontent($handle); curl_multi_remove_handle($multi, $handle); } curl_multi_close($multi)

Questions about programming?Chat with your personal AI assistant