是否可以将不同的值存储到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. 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']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.