【问题标题】:json_decode variables phpjson_decode 变量 php
【发布时间】:2011-10-01 15:42:20
【问题描述】:

我只是想从 json_decode 中提取变量

得到的解码代码(sn-p of)是:

auth_info:
array(4) {
["profile"]=>
  array(13) {
  ["name"]=>
  array(3) {
  ["givenName"]=>
  string(6) "John"
  ["familyName"]=>
  string(7) "Doe"
  ["formatted"]=>
  string(14) "John Doe"
  }
 }
}

我正在尝试所有事情,例如:

echo "\n\nMy name is ".$auth_info['profile']->name->givenName;

但一切都无济于事..请出主意?

一如既往的感谢

达伦

【问题讨论】:

  • 你应该使用print_r,而不是var_dump,来查看结构。

标签: php json parsing


【解决方案1】:

都是数组,试试这个。

$auth_info['profile']['name']['givenName']

【讨论】:

  • 非常感谢 - 它不会让我接受这个答案,这有点愚蠢,但发现......赞赏。
猜你喜欢
  • 2014-02-19
  • 2016-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多