遍历这个数组

( [0] => stdClass Object ( [term_id] => 22 [name] => Data Management [slug] => data-management [term_group] => 0 [term_taxonomy_id] => 22 [taxonomy] => topic [description] => [parent] => 0 [count] => 1 ) [1] => stdClass Object ( [term_id] => 24 [name] => High Frequency Travel [slug] => high-frequency-travel [term_group] => 0 [term_taxonomy_id] => 24 [taxonomy] => topic [description] => [parent] => 0 [count] => 1 )

我想,我们就到名项。

我尝试着:

foreach ($topicArr as $i => $row) { echo $row['name']; }

但我得到一个错误说不能使用类型stdClass的对象为数组....我真的不知道我周围怎么弄。

有任何想法吗?

--------------解决方案-------------

你的心不是排的阵列,它的一个对象,你应该使用正确的语法来获得对象的成员:

foreach ($topicArr as $i => $row) {
echo $row->name;
}

只要改变

echo $row['name'];

echo $row->name;

分类:php 时间:2015-03-15 人气:0
本文关键词: PHP
分享到:

相关文章

Copyright (C) 55228885.com, All Rights Reserved.

55228885 版权所有 京ICP备15002868号

processed in 0.236 (s). 9 q(s)