There is no, encountered this situation: using the Serialize function to serialize an array, and then want to pass the Unserialize function to reverse order, get the array, but the error, not get the desired result.
Search from the Internet, found that many netizens have encountered the same problem, it seems that this is the unserialize function of the bug.
However, fortunately someone has solved, I will jiehuaxianfo, record him for everyone to use:
1. If the data is Utf-8, use the following function to deserialize (I have no validation, can try)
function mb_unserialize ($serial _str) {
$serial _str= preg_replace ('!s: (\d+): "(. *?)";! Se ', ' s: '. strlen (' $ "). ': \ ' $2\ "; '", $serial _str);
$serial _str= str_replace ("\ R", "", $serial _str);
Return Unserialize ($serial _str);
}
2. Other encoded format data, use the following function to deserialize (the array has been validated, can be used)
function asc_unserialize ($serial _str) {
$serial _str = preg_replace(‘!s:(\d+):"(.*?)";!se‘,‘"s:".strlen("$2").":\"$2\";"‘,$ Serial_str);
$serial _str= str_replace ("\ R", "", $serial _str);
Return Unserialize ($serial _str);
}
Hope to you a little help!