多个cURL和输出JSON? [英] multiple cURL and output JSON?

查看:190
本文介绍了多个cURL和输出JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个多重卷曲并输出两个不同的数组

I have written a multiple curl and it outputs two different arrays

我使用curl_multi_getcontent。

I'm using curl_multi_getcontent.

    for($i = 0; $i < $node_count; $i++)
    {

        $results = curl_multi_getcontent  ( $curl_arr[$i]  );
        $results = json_decode($results,true);

        /*echo "<pre>";
        print_r($results);
        echo "</pre>";*/
    }

输出两个数组。如果我想从一个数组获取数据,我如何调用第一个数组?或第二个数组?

This outputs two arrays. if I wanted to get data from one of the arrays, how do I call the first array? or the second array?

有一些像$ results [0]或第一个数组的东西

Is there something like $results[0] or something for the first array

foreach($results[0] as $result){
    echo $result['pagination']; 
}


推荐答案

,$ result变量通过for循环相互覆盖。尝试此操作:

Yes, as of right now, the $result variables are overwritting each other through the for loop. Try this:

for($i = 0; $i < $node_count; $i++)
{
    $results[$i] = curl_multi_getcontent  ( $curl_arr[$i]  );
    $results[$i] = json_decode($results,true);
}

print_r($results);

您现在应该在数组中有两个元素,您可以通过 $ results [0] $ results [1] 等...

You should now have two elements in your array that you can call via $results[0] or $results[1] etc...

这篇关于多个cURL和输出JSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆