serialize/unserialize problem
| From: | Guangzu Wang | Date: | Tue, 17 Dec 2002 22:48:53 +0000 |
| Subject: | serialize/unserialize problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-128629@lists.php.net to get a copy of this message | ||
Hi,
I am working on mime message and try to pass an array with serialize and
unserialize and got some problems.
Here's some code snippet:
in my function, I have this:
$message['attachments'] = serialize($attachments);
And calling code like this:
$attachments = $message['attachments'];
echo "ATTACHMENT:$attachments<br>";
$attachments = unserialize($attachments);
echo "After unserialize:$attachments<br>";
Here's the output:
ATTACHMENT:a:1:{i:0;a:6:{s:3:"pid";i:2;s:4:"type";s:10:"image/jpeg";s:8:"enc
oding";s:6:"base64";s:4:"size";s:5:"13540";s:11:"disposition";s:10:"attachme
nt";s:4:"name";s:10:"Sample.jpg";}}
After unserialize:
It supposed to be an array after unserialize, but I got a empty result. I
used is_array() and got a false. I looked the online manual and tried those
annoying addslashes/stripslashes, nothing changed. What am I missed?
Thanks a lot for your help!
Guangzu
http://tjmu.com
http://GuangzuWang.incredibuys.com/