dqx36753 2013-04-05 21:15
浏览 7
已采纳

too long

I have a facebook array and I am trying to echo out the names and ID.

All I have is this array: $friends_list.

When I use this code:

print_r($friends_list);

Then the following comes out below: But how do I loop thru these? Or what if I just wanted to find out how many names there are or just call on one var by id. In short how do I echo out $friends_list which is a multiD array?

Array ( [data] => Array ( [0] => Array ( [name] => Wendy Cukierski [id] => 524320383 ) [1] => Array ( [name] => Leticia Mercado Correa [id] => 537763225 ) [2] => Array ( [name] => Olivia Urbina [id] => 538711855 ) [3] => Array ( [name] => Ruth Albrecht [id] => 541610111 ) [4] => Array ( [name] => Josh Brahm [id] => 577546485 ) [5] => Array ( [name] => Kim Yu [id] => 583515871 ) [6] => Array ( [name] => SisterTracey Dugas [id] => 643567171 ) [97] => Array ( [name] => Mary Martinez [id] => 100004696266210 ) ) [paging] => Array ( [next] => https://graph.facebook.com/1566027944/friends?limit=5000&offset=5000&__after_id=100004696266210 ) ) 
  • 写回答

1条回答 默认 最新

  • dsf55s1233 2013-04-05 21:17
    关注

    DUPLICATE --> How to store a Facebook user's friends list in MySQL using PHP?

    $friends_list = file_get_contents('https://graph.facebook.com/me/friends?access_token=' . $atoken );
        $friends_list_array  = json_decode($friends_list,true);
        $arr= $friends_list_array['data'];
        $friend_ids_arr = array();
        foreach($arr as $friend) {
            $friend_ids_arr[] = $friend['id'];
        }
        $friend_ids = implode("," , $friend_ids_arr);
        echo $friend_ids; // output: id1,id2,id3...etc
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真