note 70884 added to function.unserialize
| From: | eakolb at dygel dot nizzet | Date: | Thu, 02 Nov 2006 16:10:37 +0000 |
| Subject: | note 70884 added to function.unserialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119317@lists.php.net to get a copy of this message | ||
Apparently, unserialize is really picky about anyone messing with the serial string. Just spent an
hour debugging why unserialize wasn't working on a serial string stored in a database where,
per client requirement, all inserted data is strtoupper'd. Can't just strtolower on a
serial string, though -- if there are null values in there (signified as N;), they must be upper
case.
The following call may be a bit convoluted, but it works.
unserialize(preg_replace('/;n;/', ';N;', strtolower($serial)))
Of course, if you have string data within that array, that'll get clobbered by the strtolower.
In my case, I was dealing with integer values (aside from the key names). But this might save
someone else out there a little trouble.
----
Server IP: 216.194.113.175
Probable Submitter: 69.53.187.11
----
Manual Page -- http://www.php.net/manual/en/function.unserialize.php
Edit -- https://master.php.net/note/edit/70884
Del: integrated -- https://master.php.net/note/delete/70884/integrated
Del: useless -- https://master.php.net/note/delete/70884/useless
Del: bad code -- https://master.php.net/note/delete/70884/bad+code
Del: spam -- https://master.php.net/note/delete/70884/spam
Del: non-english -- https://master.php.net/note/delete/70884/non-english
Del: in docs -- https://master.php.net/note/delete/70884/in+docs
Del: other reasons-- https://master.php.net/note/delete/70884
Reject -- https://master.php.net/note/reject/70884
Search -- https://master.php.net/manage/user-notes.php