문제

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] => example@gmail.com 
    [username123] => xyz
    ) 
)
도움이 되었습니까?

해결책

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

If:

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

Then:

echo $var[0]->id;

다른 팁

Access it like any other object.

echo $array[0]->id //1
echo $array[0]->username123 //xyz

And so on. If you have multiple objects inside the array, run it through a for loop to iterate the array.

For example:

for ($i=0;$i<sizeof($array);$i++) {
    echo $array[$i]->[object property];
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top