Access array variable in session (CodeIgniter)

后端 未结 3 1463
攒了一身酷
攒了一身酷 2021-02-08 08:14

I have an array called config. I\'m trying to echo a variable from the array in the session.

I\'ve tried:

echo $this->session->userdata(\'config[\         


        
3条回答
  •  不要未来只要你来
    2021-02-08 09:11

    If config is an array . And item is string name of what you want to get from config then

    echo $this->session->userdata($config['item']);
    

    or

    echo $_SESSION[$config['item']];
    

    If config is an array inside session you should first get it.

    $tmp = $this->session->userdata('config');
    echo $tmp['item'];
    

    or

    echo $_SESSION['config']['item'] 
    

    Sorry for my english.

提交回复
热议问题