<?php
$json = file_get_contents('http://tiny.cc/ttrhelp');
$obj = json_decode($json);
$example = $obj->rooms->displayName;
?>
Name: <?php echo $example; ?>
尝试显示'displayName'的值,但不显示
答案 0 :(得分:10)
未经测试的代码:
<?php
$json = file_get_contents('http://pub.tapulous.com/tapplications/coresocial/v1/chat/api/index.php?method=room_list');
$obj = json_decode($json);
foreach($obj->rooms as $room){
$example = $room->displayName;
echo $example;
}
?>
答案 1 :(得分:5)
您可能想要$obj->rooms[0]->displayName
。
答案 2 :(得分:2)
echo $obj->rooms[2]->displayName;
答案 3 :(得分:2)
尝试
echo $obj->rooms[0]->displayName;