Access to array $this->session->array
How can i access an array like this $this->session->userdata('auth')
?
print_r() displays:
Array (
[ncli] => 0
[nomecli] => somename
[nomcli1] => Administrador
[morcli] => company
[nuser] => admin
[pwdcli] => pwdadmin
)
But I can't use $thi开发者_开发技巧s->session->userdata('auth')[ncli]
...
Put it in a variable:
$data = $this->session->userdata('auth');
echo $data['ncli'];
The reason why you can't do ()[]
is that PHP just doesn't support it yet.
You will be able to do so from PHP 5.4 where they've introduced array dereferencing. Till then use an auxiliary variable.
$auth = $this->session->userdata('auth');
$auth['ncli'];
精彩评论