Hi,
I'm thinking of storing data from a form as a string, each answer separated by a pipe. The problem I have is that some answers may come in the form of multiple items. We store the radio button selection along with their corresponding answers e.g.
Question 1 - 1 Answer [A1]
Question 2 - Radio button selected [A2] + 3 form fields
Question 3 - 1 Answer [A3]
So I was thinking of storing the data like:
$str = A1|A2[x,x,x]|A3
The reason I chose to enclose multiple selections in brackets is in order to have it relate to the question.
I think my solution will work but when I come to read the values from the database I'll use Php's explode()
to get the values into an array.
E.g. explode("|",$str);
Will give:
array(0=>A1, 1=>A2[x,x,x],2=>A3);
Before developing this, what would be the best way of getting the content of [x,x,x]
and separating it from array[1]
?
Any suggestion will be much appreciated.
Thanks