note 70884 deleted from function.unserialize by aharvey
| From: | aharvey@php.net | Date: | Tue, 06 Nov 2012 01:28:00 +0000 |
| Subject: | note 70884 deleted from function.unserialize by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191701@lists.php.net to get a copy of this message | ||
Note Submitter: eakolb at dygel dot nizzet
----
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.