原参考网址 https://blog.csdn.net/pengxuan/article/details/50520781

原因是使用 json_decode 后数组中的对象进行取值

解决方法(2种):

1、使用 json_decode($d, true)。就是使json_decode 的第二个变量设置为 true。
2、json_decode($res) 返回的是一个对象, 不可以使用 $res['key'] 进行访问, 换成   $res->key 就可以了。

原代码

$riqi = json_decode($info['giftdate'],true);   
foreach($riqi as $val)
{
  var_dump($val['rid']);
}

PHP “Cannot use object of type stdClass as array”

相关文章:

  • 2021-07-11
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-16
  • 2022-02-14
  • 2021-06-23
  • 2021-11-19
  • 2021-07-13
  • 2021-12-30
相关资源
相似解决方案