我有一个对象列表:
0 =>
object(stdClass)[550]
public 'node_title' => string 'Test' (length=4)
public 'nid' => string '1473' (length=4)
public 'node_language' => string 'nl' (length=2)
1 =>
object(stdClass)[552]
public 'node_title' => string 'Test2' (length=5)
public 'nid' => string '1321' (length=4)
public 'node_language' => string 'nl' (length=2)
2 =>
object(stdClass)[553]
public 'node_title' => string 'Test3' (length=5)
public 'nid' => string '602' (length=3)
public 'node_language' => string 'nl' (length=2)
我使用foreach循环遍历它们:
foreach($view->result as $key => $value) {
}
所以,如果每次foreach循环,就会获取1个对象,对吗?
但是如何访问对象的一个项目?我尝试过使用0->nid
,$key->nid
,但没有任何效果......我怎么能这样做?
答案 0 :(得分:2)
foreach($view->result as $key => $value) {
// Here, $value is the current object
echo($value->node_title);
}