二维会话问题与codeigniter [英] two dimension session issue with codeigniter

查看:97
本文介绍了二维会话问题与codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在会话中存储二维数组,其中我通过函数调用继续创建数组。

I want to store two dimensional array in session, where i keep creating the array through a function call.

我尝试使用这个代码

function nextQuestion($questionId,$response)
{ 
       $this->session->set_userdata("res[$questionId][]"),$response);
}

但这不是创建二维数组

推荐答案

存储在会话中的密钥必须是字符串,但该值可以是多维数组。
您可以检索数组,操作它,并将其保存在会话中,如下所示:

The key stored in the session must be a string but the value can be a multi dimensional array. You can retrieve the array, manipulate it and save it in the session again like this:

$session_response = $this->session->userdata("res");
//some manipulation on $session_response
$this->session->set_userdata('res', $session_response);

这篇关于二维会话问题与codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆