function xyz() {
$url = "http://example.com";
return $this->getdata($url);
}
function abc() {
$url = "http://example.org";
return $this->getdata($url);
}
function getdata($url) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
I have a function getdata() to retrieve remote webpages and two functions abc() and xyz() with two unique url that are to be retrieved.
Now the problem is that each request for getdata() takes around 5 seconds, I have many functions like abc() and xyz(), so calling them sequentially will cost me a lot of time.
Is there any way to call these functions simultaneously? Send multiple requests together? So no matter how many requests there are, they will always take aroung 5 seconds?