Unserialize Return False in PHP or Magento

Here is the solution 1 :
$formatted_details = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $details );
$details = unserialize( $formatted_details );

Here is the solution 2 :
It turns out that if there’s a “, ‘, :, or ; in any of the array values the serialization gets corrupted.

//to safely serialize
$safe_string_to_store = base64_encode(serialize($multidimensional_array));

//to unserialize...
$array_restored_from_db = unserialize(base64_decode($encoded_serialized_string));

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.