有没有办法为每个post变量和会话做某种while() ...就像在mysql中一样

while($row=mysql_fetch_array($result)){
echo($row['name'];
}

但要使用$ _POST

获得此结果
while($_POST){
$_SESSION['BLA'] = $_POST['BLA'];
}
有帮助吗?

解决方案

foreach($_POST as $key => $value){
echo $key . ' = ' .$value. ' <br />';
 // do whatever you want to do with these variables
}

例如,如果您只想将$ _POST中的所有内容放入$ _SESSION

$_SESSION['MyPost'] = $_POST;

其他提示

foreach($_POST as $i=>$v){
    $_SESSION[$i] = $_POST[$i];
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top