Developer
Developer

Reputation: 385

Accessing the value of an array in php

Getting stuck with the indexing problem in php codeigniter. I am trying to access the value of the key .

array(1) 
{ 
    [0]=> object(stdClass)#20 (11) 
    { 
        ["id"]=> string(1) "1" 
        ["user_id"]=> string(2) "49" 
        ["username"]=> string(0) "" 
        ["first_name"]=> string(0) "" 
        ["last_name"]=> string(0) "" 
        ["u_id"]=> string(1) "6"
    }
}

Here i am trying to get the value of the "u_id" by$u_array->u_id` but getting error.

Upvotes: 0

Views: 45

Answers (1)

Drumbeg
Drumbeg

Reputation: 1934

I think you may have to reference the key of the object stored in the array.

$u_array[0]->u_id

Upvotes: 1

Related Questions