Re: Re: $_POST variable

From: Date: Sat, 12 Mar 2011 04:09:24 +0000
Subject: Re: Re: $_POST variable
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-311788@lists.php.net to get a copy of this message
On 3/11/2011 2:43 PM, Geoff Lane wrote: [snip]
You could use foreach to iterate through the post variables until you encounter a match: foreach ($_POST as $key => $value){
     if (substr($key, 0, 6) == "radio_") {
        $buttonName = $key;
        $buttonValue = 4value;
        break 2;
     }
} I haven't tried the above code, but I hope someone will correct my efforts if I'm wrong. ok, now I am very new to php, so if i got this wrong be nice.
It APPEARS TO ME that you are setting a variable called buttonName to the extracted value stored in $key for each name in the post submission, and a variable named buttonValue for the item's value. THEM, you do the same thing again to the same destination variables for the next name/value pair, and so-on until they list of name/value pairs is exhausted. IF this understanding is correct, only the LAST name/value pair will emerge from the process intact; prior values will be obliterated. Would they not be better to append them to a single dimensioned array, which starts life as a null array? If I am getting this wrong, please administer wet mackerel therapy to my tired head and explain the facts. -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-----+ | BOX | +-----+ think

« previous php.general (#311788) next »