I'm getting a Warning: Invalid argument supplied for foreach() error message for this bit of code:
foreach($_POST['healthConditions[]'] as $key=>$value) {
if($count > 1){
$_SESSION['saFormData'] .= " $value, ";
$count--;
} else {
$_SESSION['saFormData'] .= " $value.<br>";
}
}
I've done some research that said that this warning either means you've got a string instead of an array or that the array is null. Mine is obviously an array because its data that's being passed from a form via post. However, the warning goes away if a user has checked any of the healthConditions boxes so I guess it's because the array can be returned as NULL if they don't check any. I tried putting
$_POST['healthConditions'] = array("");
and even
$_POST['healthConditions'] = array("anything");
at the beginning of the code, before the real post value gets set, but that didn't help. What else can I try? The way the form is worded, the user needs to have the option of leaving all checkboxes blank.