在php中访问数组的值

时间:2021-01-05 21:29:22

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

陷入php codeigniter中的索引问题。我试图访问密钥的值。

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.

在这里,我试图通过$ u_array-> u_id`获取“u_id”的值但是得到错误。

1 个解决方案

#1


1  

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

我想你可能必须引用存储在数组中的对象的键。

$u_array[0]->u_id

#1


1  

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

我想你可能必须引用存储在数组中的对象的键。

$u_array[0]->u_id