[英]store different post variables in a session array
是否可以将不同的值存储到php中的会话变量中,例如我有一个名为$_POST['sit']
的post变量,每次用户提交表单时该变量都使用不同的值,我想存储所有不同的值直到用户停止提交表单后,post变量才会使用,如何将post变量的所有不同值存储到会话变量数组中
You will need to start the session, check for the existence of the post variable, and then push into an array stack within the session. 您将需要启动会话,检查post变量是否存在,然后将其压入会话中的数组堆栈。 here's psuedo-code:
这是伪代码:
session_start();
if(isset($_POST['sit'])){
$_SESSION['sits'][] = $_POST['sit'];
}
Now when you var_dump($_SESSION['sits'])
it will hold reference to all of the posted values from $_POST['sit']
现在,当您使用
var_dump($_SESSION['sits'])
,它将保留对$_POST['sit']
所有已发布值的引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.