Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在这个数组上循环_Php - Fatal编程技术网

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;