Perform three functions at once

I have a php sript with three functions like this:

public function a($html,$text)
{
    //blaa
return array();
}
public function b($html,$text){
    //blaa
return array();
}
public function c($html,$text){
    //blaa
return array();
}
require_once 'simple_html_dom.php';
$a=array();
$html=new simple_html_dom();
$a=$this->a($html,$text);
$b=$this->b($html,$text);
$c=$this->c($html,$text);
$html->clear();
unset($html);
$a=array_merge($a, $c);
$a=array_merge($a, $b);


  • a($html,$text) takes 5 seconds before giving a result

  • b($html,$text) takes 10 seconds before giving a result

  • c($html,$text) takes 12 seconds before giving a result

Thus, the system takes 27 seconds before giving me the result, but I want to get the result in 12 seconds. I cannot use streams because my hosting does not support streams. How can I solve this problem?

+3
source share
3 answers

If the timeout is caused by an I / O lock (waiting for a server response), then curl_multi can help.

From the code you submitted, however, this does not seem to be your problem.

, html dom , html. , . , DomXPath.

+3

PHP . , (, ). , .

1: AJAX- , AJAX , .

2. UNIX, PHP script PHP (php xyz.php) .

: : , ​​ rabbitMQ BeanstalkD, . Laravel .

+4

You might want to look at pending jQuery objects .... $ .when should handle this situation.

+1
source

All Articles