Jump to content

Help to rewrite the function


andrewdps

Recommended Posts

Hi,

 

I've a problem modifying the code which send parallel requests to get the status from getstatuses().I've two functions say

public function getStatuses($idList)

    {

    }

public function getid($id)

    {

        $status = array();

        foreach ($id as $idList) {

            $status[] = $this->getStatuses($idList);

        }

        return $status;

    }

 

the above getid() function sends the synchronous requests to the getstatuses() function and get the status back one after another.If you need to make 5 HTTP requests and each call takes a second, your app is delayed at least 5 seconds.Now,i want to rewrite the code(if possible two functions)that speeds up the results by sending all the requests and getting back the statuses at once.Something,other friends have developed is to reverse the getstatuses() and getid() functionality.Can anybody help me writing this code

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/214201-help-to-rewrite-the-function/
Share on other sites

There's a curl multi interface for php: http://www.php.net/manual/en/function.curl-multi-add-handle.php

 

It's a bit experimental and light on the documentation however.  I had to refer back to the libcurl documentation to work out how the php interface was supposed to be used.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.