所以我将此数组保存在变量标题$arr
中。我想获取或回显 [slug] 的值
Array ( [0] => stdClass Object ( [term_id] => 11
[name] => Community Service
[slug] => community-service
[term_group] => 0
[term_taxonomy_id] => 11
[taxonomy] => category
所以我想要这样的东西
echo $arr[slug]
然后将显示“community-service”。我确信这是非常简单的事情,但我不知道如何从数组 stdClass 中获取值并将其回显在页面上。谢谢。
最佳答案
数组$arr
包含1个对象。您必须使用 ->
语法来访问它的属性。
echo $arr[0]->slug;
关于PHP 数组 stdClass 对象 - 回显值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10688650/