开发者

json_decode file_get_contents help

开发者 https://www.devze.com 2023-03-31 10:57 出处:网络
<?php $json = file_get_contents(\'http://tiny.cc/ttrhelp\'); $obj = json_decode($json); $example = $obj->rooms->displayName;
<?php
$json = file_get_contents('http://tiny.cc/ttrhelp');

$obj = json_decode($json);
$example = $obj->rooms->displayName;
?>

Name: <?php echo $example; ?>

Trying开发者_开发知识库 to show the value for 'displayName' but its not showing


Untested code:

<?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;
}

?>


You probably want $obj->rooms[0]->displayName.

CodePad.


echo $obj->rooms[2]->displayName;


Try

echo $obj->rooms[0]->displayName;
0

精彩评论

暂无评论...
验证码 换一张
取 消