Click to See Complete Forum and Search --> : strange error when printing arrays


celshader
03-20-2008, 04:13 AM
I have an array that has been serialized
The array is

$flashvars=

array(12) {
["txt_12"]=> string(0) ""
["txt_11"]=> float(1999.9)
["txt_10"]=> string(0) ""
["txt_9"]=> string(17) "H1 - Floor Guides"
["txt_8"]=> string(0) ""
["txt_7"]=> string(9) "Lacquered"
["txt_6"]=> float(2.21)
["txt_5"]=> string(7) "Sliding"
["txt_4"]=> int(2) ["txt_3"]=> int(1700)
["txt_2"]=> int(1300)
["txt_1"]=> string(0) ""
}


If I test this and try to output it using the following code

$flashvars = $_POST['flashvars'];
if(get_magic_quotes_gpc()){
$flashvars = stripslashes($flashvars);
}
var_dump (unserialize(urldecode($flashvars)));

I get the array above as the output on the page. :)

But if I use this code

$flashvars = $_POST['flashvars'];
if(get_magic_quotes_gpc()){
$flashvars = stripslashes($flashvars);
}
unserialize(urldecode($flashvars));
print $flashvars['txt_1'];
print $flashvars['txt_2'];
print $flashvars['txt_3'];
print $flashvars['txt_4'];
print $flashvars['txt_5'];
print $flashvars['txt_6'];
print $flashvars['txt_7'];
print $flashvars['txt_8'];
print $flashvars['txt_9'];
print $flashvars['txt_10'];
print $flashvars['txt_11'];
print $flashvars['txt_12'];

All I get is a line of 12 a's like so. One for each variable. :confused:

aaaaaaaaaaaa

I am trying to output the array values but all I get is letter a's

Get someone explain to me where I have gone wrong?

Thanks in advance for any suggestions.

NogDog
03-20-2008, 04:17 AM
You have to assign the result of unserialize() to a variable, so you probably want to do:

$flashvars = unserialize(urldecode($flashvars));

celshader
03-20-2008, 04:52 AM
Works perfectly now.

Thank you

:D :D :D :D :D :D