Serializing

If your string contains a ", ', :, or ; character in any of the array values the serialization will get corrupted. In order to avoid this, always base64 encode and decode along with serializing.

// Safely serialize.
$safe_string_to_store = base64_encode(serialize($array));

// Safely  unserialize...
$array_restored_from_db = unserialize(base64_decode($array));