如何获取 stdClass 对象的数组总数?
我正在尝试获取对象中数组的总数。
我正在使用 print_r 来获取以下内容以查看其中的内容。
stdClass Object ( [data] => Array ( [0] => stdClass Object ( [name] => The Drift Bible [category] => Movie [id] => 227431881228 [created_time] => 2011-02-27T21:41:04+0000 ) [1] => stdClass Object ( [name] => Shooter [category] => Movie [id] => 109671005718938 [created_time] => 2011-02-16T09:18:29+0000 ) [2] => stdClass Object ( [name] => Tron [category] => Movie [id] => 99792857339 [created_time] => 2010-11-29T03:18:06+0000 ))
这是我获取信息的代码
$movies = json_decode(file_get_contents('https://graph.facebook.com/me/movies?'
.'format=json&access_token=' . $session['access_token']));
,我再次只需要获取数组值。比如上面的about例子中的3。
我对此很陌生。任何建议都会有所帮助。
谢谢
I am trying to get the total for the Array in the Object.
I am using print_r to get the following to see whats in it.
stdClass Object ( [data] => Array ( [0] => stdClass Object ( [name] => The Drift Bible [category] => Movie [id] => 227431881228 [created_time] => 2011-02-27T21:41:04+0000 ) [1] => stdClass Object ( [name] => Shooter [category] => Movie [id] => 109671005718938 [created_time] => 2011-02-16T09:18:29+0000 ) [2] => stdClass Object ( [name] => Tron [category] => Movie [id] => 99792857339 [created_time] => 2010-11-29T03:18:06+0000 ))
here is my code to get the information
$movies = json_decode(file_get_contents('https://graph.facebook.com/me/movies?'
.'format=json&access_token=' . $session['access_token']));
Again I just need to get the Array value. Such as 3 in the about example above.
I am very new to this. Any advice will help.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:
Try:
只需调用变量键的名称
just call the name of the variable key