I have a peculiar requirement. I have a form that contains 39 groups of radio buttons with each group containing three radio buttons. When user makes choices, the results are sent via the array $_POST. This is an associative array that has the radio button name as the key and radio button value as the value.
Using the following code, I checked the keys and their values.
Is it possible to save the key as a string in a variable? Coming straight to the point, I want to write a table with 20 rows and two columns on the fly and write the key and its value.PHP Code:foreach ($_POST as $fn=>$fv){
echo "field name is $fn and has value $fv</br>";
}
----------------------------------
| apples: 20 | tomatoes : 35 |
-----------------------------------
| brinjal: 23 | pumpkin: 20 |
-----------------------------------
where apples is the key and 20 is the value of the first element of $_POST[] array. How do I do that, kindly excuse my ignorance.




Reply With Quote