如何访问像$this->session->userdata('auth')
这样的数组?
print_r()显示:
Array (
[ncli] => 0
[nomecli] => somename
[nomcli1] => Administrador
[morcli] => company
[nuser] => admin
[pwdcli] => pwdadmin
)
但我不能使用$this->session->userdata('auth')[ncli]
...
答案 0 :(得分:1)
将它放在变量中:
$data = $this->session->userdata('auth');
echo $data['ncli'];
您无法()[]
的原因是PHP just doesn't support it yet。
答案 1 :(得分:1)
您将能够从PHP 5.4中引入阵列解除引用。然后使用辅助变量。
$auth = $this->session->userdata('auth');
$auth['ncli'];