I have decoded the JSON response fron facebook using $my_friends = json_decode(file_get_contents($frens));
and print_r($my_friends);
gives the following response :
stdClass Object
(
[data] =&g开发者_运维知识库t; Array
(
[0] => stdClass Object
(
[name] => Mrinal Kumar Rai Baruah
[id] => 546111977
)
[1] => stdClass Object
(
[name] => Roshan Khangembam
[id] => 553139665
)
[2] => stdClass Object
(
[name] => Tarunesh Kumar Saurav
[id] => 620690126
)
.........................
)
)
I am new to JSON and m very confused . How can I iterate the above response to get the name ?
foreach($my_friends['data'] as $key => $val) {
echo "Friend #{$key} = {$val['name']}\n";
}
精彩评论