Last active
August 29, 2015 14:22
-
-
Save edomaru/aeb602031cc7e7ff6d34 to your computer and use it in GitHub Desktop.
Serialize-unserialize-issue
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
//to safely serialize | |
$safe_string_to_store = base64_encode(serialize($multidimensional_array)); | |
//to unserialize... | |
$array_restored_from_db = unserialize(base64_decode($encoded_serialized_string)); | |
// to update serialized data | |
$data = unserialize($serializedData); | |
if(array_key_exists('key', $data) { | |
$data['key'] = 'New Value'; | |
} | |
$serializedData = serialize($data); | |
// I found this awesome code here: | |
// http://davidwalsh.name/php-serialize-unserialize-issues | |
// http://stackoverflow.com/questions/14446029/php-update-serialized-data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment