Reputation: 2143
If i print an array $cat
i get
Array ( [1] => stdClass Object ( [cat_id] => 1 ..
Array ( [2] => stdClass Object ( [cat_id] => 2 ..
but if I try to get the cat_id
var_dump($cat->cat_id);
How can i do that?
Upvotes: 0
Views: 124
Reputation: 9403
As $cat
is an array, you need to use index
var_dump($cat[1]->cat_id);//This will work
Upvotes: 1
Reputation: 1554
If you want to get all of the cat_id
s...
foreach ($cat as $row) {
echo $row->cat_id;
}
Upvotes: 1
Reputation: 7040
$cat
is an array. You need to access the index which contains an object before you can access that object's properties:
var_dump($cat[1]->cat_id);
Upvotes: 1