dplbf4340
2013-11-11 08:24
浏览 125

在php中读取json输出

how to read below json data in php?
i have "$json = json_decode($data,true); and i tryied "$json->{'screenShareCode'};" but is is giving me an error? :(


    array(5) {
      ["screenShareCode"]=>
      string(9) "887874819"
      ["appletHtml"]=>
      string(668) ""
      ["presenterParams"]=>
      string(396) "aUsEdyygd6Yi5SqaJss0="
      ["viewerUrl"]=>
      string(65) "http://api.screenleap.com/v2/viewer/814222219?accountid=myid"
      ["origin"]=>
      string(3) "API"
    }

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • duanpei8518 2013-11-11 08:26
    已采纳

    Your output is regular array not JSON, so you access it as regular PHP array:

    $x = $array['screenShareCode']
    
    打赏 评论
  • dongshi2836 2013-11-11 08:25

    You are looking for json_encode (http://de2.php.net/json_encode)

    打赏 评论
  • dongmangsha7354 2013-11-11 08:26

    The output you are showing is not json. It seems to be a print_r'ed array.

    See http://json.org/example

    打赏 评论
  • dousi8931 2013-11-11 08:28

    What you posted is an array, not an object. Because you passed json_decode a second parameter of true, it responded with an associative array instead of an object.

    To access a property of an associative array, you can do something like $json['screenShareCode'].

    打赏 评论

相关推荐 更多相似问题