note 83415 added to function.unserialize
| From: | campbell at vertesi dot com | Date: | Sat, 24 May 2008 20:52:52 +0000 |
| Subject: | note 83415 added to function.unserialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139707@lists.php.net to get a copy of this message | ||
One thing to note - if you're storing your serialized string in a MySQL TEXT field, it will
remove the {s and }s that make your string valid for unserialization.
I almost killed myself figuring this out - I'm sure it's basic but I had to post my
solution - encode the serialized string in base 64.
$mood = array('angry','sad','happy');
$storable = base64_encode(serialize($mood));
then when you retrieve it from the database, you can access the string with
$mood=base64_decode(unserialize($storable));
----
Server IP: 64.71.164.2
Probable Submitter: 24.166.8.103
----
Manual Page -- http://www.php.net/manual/en/function.unserialize.php
Edit -- https://master.php.net/note/edit/83415
Del: integrated -- https://master.php.net/note/delete/83415/integrated
Del: useless -- https://master.php.net/note/delete/83415/useless
Del: bad code -- https://master.php.net/note/delete/83415/bad+code
Del: spam -- https://master.php.net/note/delete/83415/spam
Del: non-english -- https://master.php.net/note/delete/83415/non-english
Del: in docs -- https://master.php.net/note/delete/83415/in+docs
Del: other reasons-- https://master.php.net/note/delete/83415
Reject -- https://master.php.net/note/reject/83415
Search -- https://master.php.net/manage/user-notes.php