Ben Liu wrote:
Hi Dave,

No, that is definitely a possibility. Right now I am using a foreach
loop to iterate over the $_POST array and determine if each checkbox
is checked or not, if it is checked, than a related piece of data is
written into the text file. This makes for pretty compact code. I
could as you suggest, simply check each element in the array manually
using the associative keys rather than using a loop, that way I could
do it in any order I wished, but the code gets rather long with a line
for each checkbox. I anticipate this set of checkboxes/boolean
responses may increase in the future also, so having the loop allows
for some future-proofing.

- Ben

On 6/8/06, Dave Goodchild <[EMAIL PROTECTED]> wrote:




On 08/06/06, Ben Liu <[EMAIL PROTECTED]> wrote:


You can access the values in the $_POST array in any order, so if you know the checkbox names why not output them in the order you want? Or I am being
dumb here?



why not create an array with the keys in the order you want ( $array= array(value1,value2,....). Then loop through the array and use the values as keys to the $_POST variable and perform your processing that way.

foreach ($array as $value) {
   if (isset($_POST[$value]) {
        do something;
   }
}


--
Ron Clark
System Administrator
Armstrong Atlantic State University


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to