doumengxue7371 2011-12-12 05:37
浏览 185
已采纳

多个cURL和输出JSON?

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

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?

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

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

2条回答

  • doufu3718 2011-12-12 07:31
    关注

    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);
    

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波