duandou8120 2013-08-08 01:18
浏览 74
已采纳

如何在对象中获取'0'条目

I have the following object:

stdClass Object ( [0] => stdClass Object ( [img_id] => 56 [img_name] => 5c9eeb51930ebe222ab26895dab7c348.png ) )

It is being dumped into a variable called $image_names. I am trying to get the entry for [0].

I have tried:

$image_names->0 but I get the error: syntax error, unexpected T_LNUMBER

I even tried $image_names[0]. I realize this should not work, but I thought I would give it a try. This does not return an error. But, it also does not return the data.

In this object structure, how do I get the object associated with the key [0]?

  • 写回答

1条回答 默认 最新

  • dtt5830659 2013-08-08 01:20
    关注

    Same as always.

    $image_names->{'0'}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100