作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我将此数组保存在变量标题$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/
我是一名优秀的程序员,十分优秀!