使用foreach循环遍历数组

时间:2013-10-26 15:40:49

标签: php arrays foreach

在我正在制作的Facebook游戏中,我终于得到了这个:

$app_using_friends = $facebook->api(array(
'method' => 'fql.query',
'query' => 'SELECT uid, name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1'
));

print_r($app_using_friends);

给我这个阵列:

Array ( [0] => Array ( [uid] => 1609874007 [name] => Anne Abrams Nadel-Walbridge ) [1] => Array ( [uid] => 100000024696650 [name] => Abbye Dively ) [2] => Array ( [uid] => 100004264273000 [name] => Nelson Sheridan Crowe ) )

我玩了好几个小时,似乎无法将每个记录写入内容,以便在循环中使用php显示。

1 个答案:

答案 0 :(得分:0)

您可以像这样查看此数组:

foreach ($app_using_friends as $row) {
    echo $row['uid'] . ' ' . $row['name'];
}