Please support our PHP advertiser: Lunarpages PHP Web Hosting
![]() |
•
•
Join Date: Jul 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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.
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!
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!
![]() |
Similar Threads
Other Threads in the PHP Forum
- Session Variable clashing (ASP.NET)
- Losing session variable problem...help! (ASP)
- Need help passing a multi-dimensional array (C++)
- session variable undefined in MX 6.1, works in CF 5 (ColdFusion)
- Session variable (ASP.NET)
- session variable:again (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: Need Help getting sum of one key from flat file
- Next Thread: Email addrress in Sessions
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode