How to get data out of stdclass object?

Labeeb picture Labeeb · Aug 20, 2013 · Viewed 20.3k times · Source

I am using $this->db->get_where() to get data from database in codeigniter. Its returning following which I got using print_r()

Its looks like array of stdClass object. Anyone who how to access values inside this array.

Array ( [0] =>    
    stdClass Object ( 
    [id] => 1 
    [password321] => qwerty
    [email123] => [email protected] 
    [username123] => xyz
    ) 
)

Answer

Cups picture Cups · Aug 20, 2013

It shows an array of objects. There is only one object in it.

If:

$var =  $this->db->get_where();

Then:

echo $var[0]->id;