Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get array key identifier for queue #34

Closed
vbezruchkin opened this issue Jun 2, 2017 · 1 comment
Closed

Get array key identifier for queue #34

vbezruchkin opened this issue Jun 2, 2017 · 1 comment

Comments

@vbezruchkin
Copy link

vbezruchkin commented Jun 2, 2017

Hey all,

I believe it might be related to #14
Anyhow, I will ask :)

Here is the idea.

    $rows = [1 => 'url1', 5 => 'url2', ... ];
    $requests = [];
    foreach ($rows as $id => $url) {
        $requests[$id] = new \cURL\Request($url);
    }

Is there any way to get the key ID?

    $queue->addListener('complete', function (\cURL\Event $event) use (&$requests) {
            $response = $event->response;
            $content = $response->getContent(); // Returns content of response

// TODO: get id here

            if ($next = array_pop($requests)) {
                $event->queue->attach($next);
            }
    });

    $queue->attach(array_pop($requests));
    $queue->attach(array_pop($requests));
    $queue->send();

Thanks in advance.

@vbezruchkin
Copy link
Author

Sorry, resolved :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant