有没有办法为每个post变量和会话做某种while()
...就像在mysql中一样
while($row=mysql_fetch_array($result)){
echo($row['name'];
}
但要使用$ _POST
获得此结果while($_POST){
$_SESSION['BLA'] = $_POST['BLA'];
}
答案 0 :(得分:3)
foreach($_POST as $key => $value){
echo $key . ' = ' .$value. ' <br />';
// do whatever you want to do with these variables
}
或
例如,如果您只想将$ _POST中的所有内容放入$ _SESSION
$_SESSION['MyPost'] = $_POST;
答案 1 :(得分:1)
foreach($_POST as $i=>$v){
$_SESSION[$i] = $_POST[$i];
}