I'm trying to implement a polling system where if the user lands on a particular poll page and actually answers the question, then the id and their option will be logged. For example, let's say the id of that question is 67 and they answered option 2, then I want the array to look something like this:
67:2. The log array data will be kept in a
SESSION variable, and each time the user answers a question it'll add on to this array. When the user tries to navigate to a poll he/she answered already, then it'll display the answered option.
I know I could use concatenate and the
in_array function if this was an array of only numbers, like
"3,2,1,5,6" but how can I do this for this type of array?
("3:1, 2:2, 1:1") where the first digit is the id and the second digit is the option chosen. How do I use
if (in_array($id)) when after concatenation it'll be something like this