php循环关联数组 [英] php loop through associative arrays
本文介绍了php循环关联数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Stackoverflow 上编辑这段代码,我真的很接近得到我需要的结果.
Editing this code here on Stackoverflow and I'm really near to get the result I need.
所以我把这段代码贴在这里:
So I have this code posted down here:
$friends = $facebook->api('/me/friends');
if(!empty($friends['data'])){
$size = variable_get('facebook_graph_pic_size_nodes','square');
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
foreach($friends['data'] as $data){
$fbid = $data['id'];
$fbfriendlikes[$fbid]=$facebook->api('/'.$fbid.'/likes');
}
$fbfriendlikes
向我输出这样一个数组:http://penelope-ns.net/fb/fig.jpg
The $fbfriendlikes
outputs me an array like this one : http://penelope-ns.net/fb/fig.jpg
我需要做的是将名称保存在 $return
值中,所有名称.
What do I need to do is save the names in a $return
value, all names.
有人可以帮我解决这个问题吗?谢谢.
Can someone please help me with this? Thanks.
推荐答案
这应该可行.
$dataArray = $fbfriendlikes[$data['id']]['data'];
$result = "";
foreach($dataArray as $item){
$result .= " ".$item['name'];
}
这篇关于php循环关联数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文