Management of multidimensional codeigniter arrays

0

Good morning. I have an arrangement to save the information of the session that I will use, it is sent to me by multidimensional arrangement but I have not been able to access the data, I can only see them through print_r. Annex result of print_r.

I appreciate your support, regards!

    
asked by Ismael 08.05.2018 в 20:29
source

1 answer

0

Assuming that your array is stored in the variable $ user, to access you must use two indexes. The first is the user data, and the second is the field you want to access. For example, to access the name:

$ user ['username'] ['name']

Keep in mind that to do this you must know the keys (indices) of the second level. If you need a list of these indexes, you can obtain it with:

array_keys ($ user ['username'])

The latter would return an array such that:

array(
    '__ci_last_regenerate',
    'logged_in',
    'username',
    'usuariovalido',
    ...
)
    
answered by 09.05.2018 в 09:37