Hi again,
I'm stumped. I'd like to store results from a questionnaire in a multi-dimensional session variable to tally the number of questions answered after the entire questionnaire is completed. Users choose selections from checkboxes, so I have that info coming from an array. I was hoping I could just create an array of answers, keyed by the question, but I'm having some issues. Here is a code snippet.
//items is the checkbox
//$curr is a string created designating the question
$answers = $_POST['items'];
if (count($answers) > 0)
{
$_SESSION['answers'][$curr]=$answers;
print_r($_SESSION['answers']);
}
When I print out the contents of the array, it gives me:
Array ( [0] => 31 [1] => 32 [2-2] => Array ( [0] => 31 [1] => 32 [2-2] => Array *RECURSION* ) )
I feel like it should be:
Array( [2-2] => Array ( [0] => 31 [1] => 32 )
At least that's what I want to happen. I also only have one php page and depending on what's passed into the url, different questions are shown. Because of this, it seems like my answers array isn't adding the new arrays.
Weird thing is when I hardcoded everything, this worked just fine. Now that I want it more dynamic, it isn't working. Any ideas? Or maybe there's some other way I'm not seeing. TIA!