I posted an earlier thread on how to combine array values, and marked that thread as resolved. Well, it's not. 🙂 I have a new problem / question...
So, if I print_r($_POST) the values from my form, I'll get something like this:
Array ([example1] => tree [testing1] => green [example2] => flower [testing2] => red [example3] => mountain [testing3] => brown [example4] => ocean [testing4] => blue )
This code:
$key = '';
$i = 0;
$output = array();
foreach($array as $val)
{
if( ($i++ % 2) == 0 ) $key = $val;
else $output[$key] = $val;
}
Will yield this:
Array ([tree] => green [flower] => red [mountain] => brown [ocean] => blue )
Which is exactly what I wanted.
However, my new question is this:
In the event that the user did not enter a value in one of the fields, how can I set that value to "None". So, if the user never typed "tree" for example, how can I set that to "None"?
I'd like to figure out how to do this after the form has already been submitted, so I don't want to set any default values for the text fields.