views:

167

answers:

2

Is there any way to do some kind of while() for each post variable and session it up... like in mysql

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

But to get this result with the $_POST

while($_POST){
$_SESSION['BLA'] = $_POST['BLA'];
}

Thanks in advanced :)

A: 
foreach($_POST as $i=>$v){
    $_SESSION[$i] = $_POST[$i];
}
Luca Matteis
+3  A: 
foreach($_POST as $key => $value){
echo $key . ' = ' .$value. ' <br />';
 // do whatever you want to do with these variables
}

Or

just for example, if you just want to put all of those in $_POST into $_SESSION

$_SESSION['MyPost'] = $_POST;
Wbdvlpr
This method is preferable as it means your post information is stored in a sub-array, so that it won't replace any other SESSION elements you may already have present.
Lachlan McDonald
exactly. :-) ...
Wbdvlpr