note 93606 deleted from function.unserialize by googleguy
| From: | googleguy@php.net | Date: | Wed, 19 Jun 2013 05:55:35 +0000 |
| Subject: | note 93606 deleted from function.unserialize by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-195268@lists.php.net to get a copy of this message | ||
Note Submitter: chaos
----
The methods here for correcting string lengths in UTF-8 encoded serialized data weren't
reliable for me; various of the data I had stored broke them. This is the method that handled all
of my cases:
<?php
$serialized = preg_replace_callback(
'!(?<=^|;)s:(\d+)(?=:"(.*?)";(?:}|a:|s:|b:|d:|i:|o:|N;))!s',
'serialize_fix_callback',
$serialized
);
function serialize_fix_callback($match) {
return 's:' . strlen($match[2]);
}
?>
[EDITOR thiago NOTE: This note has fixes from user "w33ble"]