But, assuming you aren't worried about validating, you could do like this:
$_SESSION['age'] = $_POST['age'];
But, honestly, I would still use the foreach loop, check the values of $name and $age to make sure they are legal, and in the correct format, and then assign them individually, as before.
Jeff
Jeff Schmidt wrote:
I would be tempted to do the following.
First, I would setup the html form so that the text boxes are named something like 'age[Andrea]', 'age[Bob]', etc. When the form submitted, this will give you an array, accessible as $_POST['age'] (or $_GET['age'] depending on whether you used POST or GET form submission method).
This array would look like ("Andrea" => "25", "Bob" => "13", etc).
Then, I would use the following:
foreach($_POST['age'] as $name => $age) { setcookie("cookie[$name]", $age); }
[snip]
With that in mind, I would alter my above code to be the following:
foreach($_POST['age'] as $name => $age) { $_SESSION['age'][$name] = $age; }
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php