My final question.
I have values which have been serialized into a table forum_polls as are in the following format as shown in the two examples below:
a:2:{i:0;a:2:{s:6:"answer";s:3:"Yes";s:5:"votes";s:1:"1";}i:1;a:2:{s:6:"answer";s:2:"NO";s:5:"votes";s:1:"2";}}
a:5:{i:0;a:2:{s:6:"answer";s:2:"CA";s:5:"votes";s:1:"1";}i:1;a:2:{s:6:"answer";s:4:"CIMA";s:5:"votes";s:1:"1";}i:2;a:2:{s:6:"answer";s:4:"ACCA";s:5:"votes";s:1:"0";}i:3;a:2:{s:6:"answer";s:5:"CIPFA";s:5:"votes";s:1:"1";}i:4;a:2:{s:6:"answer";s:24:"MBA(specify in comments)";s:5:"votes";s:1:"1";}}
which unsererilized (I cheated and used an online unserializer) give:
array (
0 =>
array (
'answer' => 'Yes',
'votes' => '1',
),
1 =>
array (
'answer' => 'NO',
'votes' => '2',
),
)
and
array (
0 =>
array (
'answer' => 'CA',
'votes' => '1',
),
1 =>
array (
'answer' => 'CIMA',
'votes' => '1',
),
2 =>
array (
'answer' => 'ACCA',
'votes' => '0',
),
3 =>
array (
'answer' => 'CIPFA',
'votes' => '1',
),
4 =>
array (
'answer' => 'MBA(specify in comments)',
'votes' => '1',
),
)
Basically there are three pieces of information for each possible answer:
id e.g. 0,1,2,3,4 etc
answer e.g. MBA(specify in comments)
votes - i.e. the number of votes received
Of course there are polls with different number of answers etc.
What I need to do is take:
topic_id from forum_polls and
unserialize the values which are contained in table forum_polls column poll_answers
and then insert the following into table forum_poll_options
topic_id into topic_id
id into option_id
answer into option_text
votes into option_total
Can anyone help please as I haven't experience of dealing with arrays.
Thanks
Mark