Reputation: 8103
I've got a list of objects:
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)
And I loop over them using a foreach loop:
foreach($view->result as $key => $value) {
}
So, if every time the foreach loops, 1 object is fetched, right?
But how can I access one item of the object? I've tried with 0->nid
, $key->nid
,... but nothing worked... How can I do so?
Upvotes: 1
Views: 265
Reputation: 24661
foreach($view->result as $key => $value) {
// Here, $value is the current object
echo($value->node_title);
}
Upvotes: 2