Mulit-byte Unserialize
Join the DZone community and get the full member experience.
Join For FreeIf you put a serialized string in an HTML form on a UTF-8 page you'll likely need to use this function when processing the form.
/**
* Mulit-byte Unserialize
*
* 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);
}
Opinions expressed by DZone contributors are their own.
Comments