loop over this array
(
[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
)
)
And i want to get at the name entry.
I'm trying:
foreach ($topicArr as $i => $row) {
echo $row['name'];
}
but i get开发者_StackOverflow中文版 an error saying Cannot use object of type stdClass as array in....I'm really not sure how I get around it.
Any ideas?
Your row isnt an array, its an object, you should use the proper syntax to get members of objects:
foreach ($topicArr as $i => $row) {
echo $row->name;
}
just change
echo $row['name'];
to
echo $row->name;
精彩评论