Online Shopping : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

18 of 20 people (90%) answered Yes
Recently 10 of 10 people (100%) answered Yes


What is the best way to send an 'unknown' number of form fields and access them on the text page?

Nov 27th, 2008 14:29
healthy man, dman, Jeroen Keppens, John McCaskill,

// First reset the array storing all values recieved from the form
reset ($HTTP_POST_VARS);   // if form method="post"
reset ($HTTP_GET_VARS);    // if form method="get"
// First way : with "while loop"
while (list($key, $value) = each ($HTTP_POST_VARS)) {
    echo "Key: $key; Value: $value<br>\n";
// Second way : with "foreach"
foreach ($HTTP_POST_VARS as $key => $value) {
    echo "Key: $key; Value: $value<br>\n";
I hope this answers your question