Created
September 13, 2016 06:41
-
-
Save blessdyb/2b2f31a24e34f2c8da3733d49863c750 to your computer and use it in GitHub Desktop.
PHP unserialize utf8 fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Mulit-byte Unserialize (http://stackoverflow.com/questions/2853454/php-unserialize-fails-with-non-encoded-characters) | |
* | |
* UTF-8 will screw up a serialized string | |
* | |
* @access private | |
* @param string | |
* @return string | |
*/ | |
function mb_unserialize($string) { | |
$string = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $string); | |
return unserialize($string); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment