我正在尝试遍历一个名为items
包含数组的对象属性:
foreach ($this->footerList->items as $item)
当我执行该语句时,我收到一条错误消息 - “尝试获取非对象的属性”,即使
var_dump($this->footerList)
表明$this->footerList
确实包含一个items
数组。
object(FooterModel)#13 (1)
{
["items"]=> array(3)
{
[0]=> array(5)
{
["id"]=> string(20) "terms-and-conditions"
["title"]=> string(20) "Terms and Conditions"
["url"]=> string(23) "home/termsandconditions"
["label"]=> string(20) "Terms and Conditions"
["authenticatedOnly"]=> string(5) "false"
}
[1]=> array(5)
{
["id"]=> string(14) "privacy-policy"
["title"]=> string(14) "Privacy Policy"
["url"]=> string(18) "home/privacypolicy"
["label"]=> string(14) "Privacy Policy"
["authenticatedOnly"]=> string(5) "false"
}
}
}
有人可以帮我弄清楚为什么循环语句无法解决$this->footerList->items
?