Php 在这个数组上循环
) 我想进入名字入口 我正在努力:Php 在这个数组上循环,php,Php,) 我想进入名字入口 我正在努力: ( [0] => stdClass Object ( [term_id] => 22 [name] => Data Management [slug] => data-management [term_group] => 0 [term_taxonomy_id] => 22 [taxonomy] => topic
(
[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
)
但我得到一个错误,说不能使用stdClass类型的对象作为数组在…我真的不知道我如何绕过它
有什么想法吗?您的行不是数组,而是对象,您应该使用正确的语法来获取对象的成员:
foreach ($topicArr as $i => $row) {
echo $row['name'];
}
换衣服
foreach ($topicArr as $i => $row) {
echo $row->name;
}
到
echo $row['name'];
echo $row->name;