Tough problem: Serializing a multiple select array
Posted: Thu Apr 22, 2004 1:22 am
Hello array freaks,
Last Tuesday I had a discussion with Mark about passing a multiple select array through several forms (viewtopic.php?t=21223). Marks help was very welcome, but the problem is unfortunately still not completely solved. I was hoping one of you could help me with it.
Summarizing the discussion, Mark told me, I had to serialize my title-array (one person can have several titles and therefore this array comes from a multiple select list), before posting my second form. I tried to do so, but when I am printing my arrays, it looks like this:
// After posting it from the first form -> everything OK
Array ( [0] => Prof [1] => Mr )
// The data arrives as it should at the second form, but after posting it
// from the second form, it isn't OK anymore. I tried two options:
OPTION 1: Adding the title-array as a hidden value to the second form
// After posting and before unserializing
Array ( [0] => a:3:{i:0;s:4: )
// After unserializing
Array ( [0] => a:3:{i:0;s:4: [1] => )
// By the way, the code of the hidden field is as follows:
ECHO "<INPUT TYPE=\"hidden\" NAME=\"title[]\" VALUE=\"".serialize($titel)."\">";
OPTION 2: Using serialize($title) directly in the action-command
// After posting and before unserializing
Array ( [0] => a:3:{i:0;s:4: )
// After unserializing
Array ( [0] => serialize(Array) [1] => )
Any idea what could be wrong this time? How can I get the original array-data back?
Thanks already for the answer,
Antonie
Last Tuesday I had a discussion with Mark about passing a multiple select array through several forms (viewtopic.php?t=21223). Marks help was very welcome, but the problem is unfortunately still not completely solved. I was hoping one of you could help me with it.
Summarizing the discussion, Mark told me, I had to serialize my title-array (one person can have several titles and therefore this array comes from a multiple select list), before posting my second form. I tried to do so, but when I am printing my arrays, it looks like this:
// After posting it from the first form -> everything OK
Array ( [0] => Prof [1] => Mr )
// The data arrives as it should at the second form, but after posting it
// from the second form, it isn't OK anymore. I tried two options:
OPTION 1: Adding the title-array as a hidden value to the second form
// After posting and before unserializing
Array ( [0] => a:3:{i:0;s:4: )
// After unserializing
Array ( [0] => a:3:{i:0;s:4: [1] => )
// By the way, the code of the hidden field is as follows:
ECHO "<INPUT TYPE=\"hidden\" NAME=\"title[]\" VALUE=\"".serialize($titel)."\">";
OPTION 2: Using serialize($title) directly in the action-command
// After posting and before unserializing
Array ( [0] => a:3:{i:0;s:4: )
// After unserializing
Array ( [0] => serialize(Array) [1] => )
Any idea what could be wrong this time? How can I get the original array-data back?
Thanks already for the answer,
Antonie